没有一个。使用常量的final类将它们声明为public static final和static在任何必要的时候导入所有常量。
public final class Constants {
private Constants() {
// restrict instantiation
}
public static final double PI = 3.14159;
public static final double PLANCK_CONSTANT = 6.62606896e-34;
}
用法:
import static Constants.PLANCK_CONSTANT;
import static Constants.PI;//import static Constants.*;
public class Calculations {
public double getReducedPlanckConstant() {
return PLANCK_CONSTANT / (2 * PI);
}
}