有如下类定义: class Test{ private int b; public int c(Test a){ int i; return i+a.b; } } 按照类中关于私有的实例变量的理解,a是一个Test的对象,那么实例成员变量b由于是私有的,应该不能利用a.b来访问,但程序中该编译是可以通过的,而且也能正常运行得到结果。 我不知道大家对此是怎么理解的?
像这种程序也是可以执行的
public class Test {
private static int xxx=99; //私有变量
public static void main(String[] args) {
Test ww=new Test();
System.out.println(ww.xxx); //访问私有变量
}
}