Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
    Bookmark Topic Watch Topic
  • New Topic

Static mmbers

 
jack worthing
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Report post to moderator
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
Posts: 1710
  • Mark post as helpful
  • send pies
  • Report post to moderator
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
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
  • Report post to moderator
Can we carry on the discussion of this question in this duplicate post
 
    Bookmark Topic Watch Topic
  • New Topic