Hi there, Have you heard about the "Hide Local Variables" in java. This is somebody asked my in an interview. Can you tell my anything about this. Thanks for any help
Joined: Nov 07, 2000
Well, if you declare them inside of a method then you've basically 'hidden' them from class scope. You can also do the following
Hope this helps. Sean
Joined: Nov 10, 2000
Thanks Sean! Is this the concept called Hiding local variables.
Joined: Jul 11, 2001
No, it isn't. Hiding local variables is not allowed in java. If it would, you could write something like:
That is, the inner variable i "hides" the outer variable of the same name. In Java, the above code gives a compile time error. On the other hand, local variable *can* hide member variables, as you probably know.
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus