放在类里,而且这个类是final型的

解决方案 »

  1.   

    其实对于Constants类,定义成类还是接口都一样,看各人了,只不过如果是类就要写成如
    public static final String CLEAR_PER_DAY = "1";而接口则直接写成String CLEAR_PER_DAY = "1";就可以了,一般做大型项目,如果需要定义的常量很多,习惯用接口,原因很简单,接口可以套接口,这样你的常量无形中就实现了分类,是好的编码规范哦^_^~~~
      

  2.   

    Normally, the constant will be defined in the class as attribute instead of defining in the interface. 
    1. if you define the constant in the class file, then all the subclass will be have the same set of constants because the constant is an attribute of the class.
    2. if you define the constant in the interface, then all classes implement the interface will be able to those constant.