总是我想在那里把常数,在这样的接口:在类或接口中声明常量的更好的地方是什么?
public interface MyInterface {
...
public static final String MY_CONST = "const";
...
}
或者像类:
public class MyClass implements MyInterface {
...
public static final String MY_CONST = "const";
...
}
有什么更好的地方来定义常量?
类。在有效的Java中讨论。 –
为什么要上课?你能解释一下吗? – Jdoe
http://stackoverflow.com/a/66307/139010和http://stackoverflow.com/questions/2659593/what-is-the-use-of-interface-constants –