wood burning stoves 2.0
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 REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "static variable" Watch "static variable" New topic

static variable

vikas mhatre

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

Joined: Jan 10, 2002
Posts: 63548

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] [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

Joined: Apr 24, 2010
Posts: 26
Thanks Bear
I agree. Here's the link: http://aspose.com/file-tools
subject: static variable
It's not a secret anymore!