This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes static variable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "static variable" Watch "static variable" New topic
Author

static variable

vikas mhatre
Greenhorn

Joined: Apr 24, 2010
Posts: 26
As I know we can't access instance variable from static method.



Here a and b both are not static still we can access b but not a why?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60740
    
  65

b is neither an instance or a static variable. It's a local variable to the method and is in scope from its declaration to the end of the method.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
rewati raman
Ranch Hand

Joined: May 22, 2010
Posts: 62
a and b are not static as static key word is not used.
b is a local variable and can be accessed in main method. where as a can be accessed through out the class test.
vikas mhatre
Greenhorn

Joined: Apr 24, 2010
Posts: 26
Thanks Bear
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: static variable
 
Similar Threads
confusion with static variable....
static : Bug in K&B P-145
Method question
Doubt: Main method
Overridding Pls Explain this code