This week's book giveaway is in the General Computing forum.
We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes shadow variable Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Reply Bookmark "shadow variable " Watch "shadow variable " New topic
Author

shadow variable

rex tony
Ranch Hand

Joined: Aug 29, 2007
Posts: 159
Good afternoon,
What is shadow variable in java?Give me any example
Regards
Rex
sathi jogi
Greenhorn

Joined: Aug 31, 2007
Posts: 14
hi,
shadow variable nothing but, declaring a variable within the local scope/method with the same name as in global scope.

while running, vm always considers local variable.

Example:
public class TestShadow
{
int size =10;

public void method(int size)
{
size = 30;
syso(" I'm in local"+size)
}
}
public static void main(String[] args) {
int size =100;
TestShadow ts = new TestShadow();
ts.method(size);
System.out.println(" I'm in main"+ts.size--);
System.out.println(" local method value"+size);
}
}
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: shadow variable
 
Similar Threads
interface question
Method Local Inner class cannot access Final local Variables Problem
Variable shadowing
scope...
static-in interface