as I declare a table of strings in all java testss and functions , is it possible de declare it once in an interface and to call it anywhere ?
public interface string {
string[] mytab = new string[2];
}
in the开发者_StackOverflow java class :
public class Test { }
How can I call the inetrface to say :
if (mytab[1].equals("toto")){}
I guess this is what you are asking about. This should work for you.
public interface MyInterface {
static final String myString = "abc";
}
public class Test {
static void test() {
if (MyInterface.myString.equals("abc")) {
// ...
}
}
}
I believe you can define static objects in an interface.
精彩评论