引用final static 的常量編譯后存儲常量而不是引用
//One.java
public class One {
public final static String str ="aaaaaaa";
}
//Two.java
public class Two {
String bb = One.str;
}
編譯后:
//One.class
public class One
{
public final static String str = "aaaaaaa";
}
//Two.class
public class Two
{
String bb = "aaaaaaa";
}
如果修改 One.java 后編譯One.java ,Two.java存儲的還是舊值噪奄,所以需要都編譯