aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Static variables and scoping Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Static variables and scoping" Watch "Static variables and scoping" New topic
Author

Static variables and scoping

John Lincoln
Ranch Hand

Joined: Feb 11, 2003
Posts: 192
Hi,
Can you same variable name for member variable and for variables in the method ? Is this because instance variables are on heap and local variables on stack ?

System.out.println(this.i); in the below code prints "10",which shows that static variable has been re-assigned.

How to tackle these type of questions


Keith Lynn
Ranch Hand

Joined: Feb 07, 2005
Posts: 2367
Yes you can. This is called shadowing.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Static variables and scoping