Skip to content

Instantly share code, notes, and snippets.

@nicolasxu
Created January 10, 2016 20:06
Show Gist options
  • Save nicolasxu/dcad13cbb92f782990f3 to your computer and use it in GitHub Desktop.
Save nicolasxu/dcad13cbb92f782990f3 to your computer and use it in GitHub Desktop.
Manage Constants in Project
// definition
public final class Constants {
private Constants() {
// restrict instantiation
}
public static final double PI = 3.14159;
public static final double PLANCK_CONSTANT = 6.62606896e-34;
}
//Usage :
import static Constants.PLANCK_CONSTANT;
import static Constants.PI;//import static Constants.*;
public class Calculations {
public double getReducedPlanckConstant() {
return PLANCK_CONSTANT / (2 * PI);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment