File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Static mmbers

 
jack worthing
Greenhorn
Posts: 18
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
if static methods are restricted to call only static methods and data,
how can main() be static and yet call any kind of methods or data.
 
Paul Yule
Ranch Hand
Posts: 229
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not quite sure what you mean:

 
Joanne Neal
Rancher
Pie
Posts: 3742
16
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could however create an instance of the StaticTest class and then access the fields/call the methods using that
[ December 02, 2008: Message edited by: Joanne Neal ]
 
Paul Yule
Ranch Hand
Posts: 229
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jack, perhaps your confusion is that you are creating non-static variables inside the static method and calling non static methods/variables on those instances, like Joanne said. The main method does indeed act like every other static method though.
 
jack worthing
Greenhorn
Posts: 18
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thankyou for concern
i'm answerd .
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic