我想了解保护和封装acesses的想法,我已经试过编译器,但它不停地告诉我,有一个问题保护和包访问
public class example{
int s = example2.v;
public static void main(String args[]){
}
}
public class example2 {
int v = 0 ;
}
谁能帮我这个?它为什么说:
非静态变量v不能从静态上下文中引用。
变量's'不是静态的!
请通过以下链接:http://www.javatutorialhub.com/java-static-variable-methods.html –
http://stackoverflow.com/questions/2559527/non-static-variable-cannot-be-referenced -from-a-static-context-java 检查此.. – Sanath