Can a static variable of a class can be accessible with in the class's constructor ? For ex Class Test { static int total = 10; Test() { int temp = total; } }
Yes. I compiled. But my doubt was, a static variable is accessed by only static methods and since constructors can not be static,I am confused. Thanks Charu
No. A static variable can be accessed by static and instance methods of that class. Instance variables, however, can only be accessed by instance methods of that class.