Neither one. Use final class for Constants
declare them as public static final
and static import all constants wherever necessary.
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);
}
}
See wiki link : http://en.wikipedia.org/wiki/Constant_interface
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…