Above code compiles & run fine but if i will remove comments then it gives compile time error. whcih is true we cannot access private variables out side a class.
But why we are able to declare static variables with private access in a class. As we all know private means we can access that variable only with in that class. But static means we can access the that variable withouht having instance of class & outside of the class.
Any pointer why java allows static & private keyword in same declaration. Or Any explanation
private means that the variable can only be accessed by "test" objects. While it is true that static mean that it can be accessed without an instance, static also means that there is one copy for all "test" objects.
Henry [ January 24, 2006: Message edited by: Henry Wong ]