R
Ravi Shankar Nair
Dear all,
Today I was part of a fruitful discussion. But that left me in mere
oblivion.
A static method cannot access non static members of the class. Well, thats
fine and clear.
But a non static method ( or instance method) can access a static variable
in Java!!!
But a non static method is basically doing an instance service. Hence how
come instance service be allowed to manipulate a class variable ( or static
variable ) ? Surely C++ throws an exception, and is that not a drawback in
Java language syntax?
Or anyone please suggest a situation where instance service has to
manipulate a class variable ? Constructor makes sense, and let constructors
be the only functions which has the power to do both instance and class
service. But other than constructors, every other instance method should be
disallowed to use a class variable, right?
Please share your comments, thanks. Just for the discussion and value added
remarks, I am keeping the post to comp.object as well.
Regards,
Ravi
Today I was part of a fruitful discussion. But that left me in mere
oblivion.
A static method cannot access non static members of the class. Well, thats
fine and clear.
But a non static method ( or instance method) can access a static variable
in Java!!!
But a non static method is basically doing an instance service. Hence how
come instance service be allowed to manipulate a class variable ( or static
variable ) ? Surely C++ throws an exception, and is that not a drawback in
Java language syntax?
Or anyone please suggest a situation where instance service has to
manipulate a class variable ? Constructor makes sense, and let constructors
be the only functions which has the power to do both instance and class
service. But other than constructors, every other instance method should be
disallowed to use a class variable, right?
Please share your comments, thanks. Just for the discussion and value added
remarks, I am keeping the post to comp.object as well.
Regards,
Ravi