| Author |
Regarding static
|
santhosh kumar vk
Ranch Hand
Joined: Aug 25, 2009
Posts: 115
|
|
Hi
I have one doubt that is in static method we can not use non static variable then how it is possible in public static void main(String args[]) can you explain
Thanking you.
|
 |
John de Michele
Rancher
Joined: Mar 09, 2009
Posts: 600
|
|
Santhosh:
It isn't possible in a main() method, either. However, you can create a local instance like this:
Running the main() method should print out 'bar'.
John.
|
 |
pankaj vijay
Ranch Hand
Joined: Apr 01, 2008
Posts: 75
|
|
|
in static method we cann't access instance(non static) variables. but when you are in static method you can not declare static variable BUT you can declare local variable that will be non static. As static variable belongs to class not to method.
|
Pankaj Vijay (SCJP, SCBCD)
Learn Core Java,Learn Servlet Jsp, SCJP Questions,Struts Tutorial
|
 |
 |
|
|
subject: Regarding static
|
|
|