Spot false dilemmas now, ask me how!
(If you're not on the edge, you're taking up too much room.)
Spot false dilemmas now, ask me how!
(If you're not on the edge, you're taking up too much room.)
What about the fact that class dog is method-local class, so therefore it cannot access any variables inside its class that are not marked final!!
Originally posted by Damien Howard:
To access the size vars with the animal reference follow Kathy's advice, but to just access the size vars in general you can do the following:
Originally posted by Lalitha Chandran:
Hi all
I apologise for the previous post.
But the point I wanted to convey is if a Local Inner Class (a class declaration within a method code) hides an instance variable (example size) there is no way of accessing that instance variable. Please correct me if I am wrong.
Although this can be done in an Inner class (class declaration within a class) using the Damien suggested.
Lalitha
Originally posted by Lalitha Chandran:
The point I want to convey is if a Local Inner Class (a class declaration within a method code) hides an instance variable (example size) there is no way of accessing that instance variable. Please correct me if I am wrong.
Although this can be done in an Inner class (class declaration within a class) using the Damien suggested.
Thanks
Lalitha
Originally posted by Sudhakar Krishnamurthy:
If i add an access method to the class dog/Animal
and when i do a.giveMeTheSize() will return 37 due to polymorphism.
So why is this inconsistency in the behavior
a.size //returns 42
a.giveMeTheSize() //returns 37
Can anyone explain??
[ July 22, 2003: Message edited by: Sudhakar Krishnamurthy ]
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime. |