my dog learned polymorphism
The moose likes Beginning Java and the fly likes Static mmbers Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Reply locked New topic

Static mmbers

jack worthing

Joined: Dec 02, 2008
Posts: 18
if static methods are restricted to call only staic methods and data,
how can main() be static and yet call any kind of methods or data.
Chandra Bhatt
Ranch Hand

Joined: Feb 28, 2007
Posts: 1710
Hi Jack,

Welcome to JavaRanch!!!

How do you find your statement to be correct?
Can you come up with an example?

Static method can't access non-static method or instance member, because
there is no "this" reference in it. The same applies to main() method also.

Joanne Neal

Joined: Aug 05, 2005
Posts: 3742
Can we carry on the discussion of this question in this duplicate post

I agree. Here's the link:
subject: Static mmbers
jQuery in Action, 3rd edition