File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes Hide Local Variables Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Hide Local Variables" Watch "Hide Local Variables" New topic
Author

Hide Local Variables

Ramneek Handa
Ranch Hand

Joined: Nov 10, 2000
Posts: 44
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
Sean MacLean
author
Ranch Hand

Joined: Nov 07, 2000
Posts: 621
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
Ramneek Handa
Ranch Hand

Joined: Nov 10, 2000
Posts: 44
Thanks Sean!
Is this the concept called Hiding local variables.
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Hide Local Variables