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
 
my overalls have superpowers - they repel people who think fashion is important. Tiny ad:
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic
Boost this thread!