• Post Reply Bookmark Topic Watch Topic
  • New Topic

static main method question  RSS feed

 
Vonique Leary
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm confused about the main method and why an object of the same class can be instantiated in it. For example:



Does the static main method not go with that new object instantiation? Meaning, when the peppermint object is created, does it not contain that same static main method that is in the Candy class? If it did, it would be creating itself over again, wouldn't it? I know this probably makes sense to you who are experienced, but I'm a beginner who needs baby explanations. Thank you, Von
 
Ankit Garg
Sheriff
Posts: 9610
37
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Vonique methods are not part of objects. Only fields are part of objects. So when you create an object, then a copy of methods (static and non-static) is not created...
 
Vonique Leary
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Okay, well that makes a lot more sense now. Thank you for the explanation!

Vonique
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!