| 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); } }
|
 |
 |
|
|
subject: shadow variable
|
|
|