File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes Regarding static Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Regarding static" Watch "Regarding static" New topic
Author

Regarding static

santhosh kumar vk
Ranch Hand

Joined: Aug 25, 2009
Posts: 144
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
 
wood burning stoves
 
subject: Regarding static
 
Similar Threads
doubt about import static
overloading static methods?
Static Method Overriding
question about ArrayList
Using static