Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

public static void main(String agrs[])

 
Minal Silimkar-Urankar
Ranch Hand
Posts: 136
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
java main() method is in which class?
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is in whichever class you put it in

A Java application needs a main method to start. This is the interface the Java runtime uses to call into your code.
 
Piyush Porwal
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
or what he means to say is: if you fire "java ClassName", ClassName should have this.
 
Minal Silimkar-Urankar
Ranch Hand
Posts: 136
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Paul Sturrock

It is in whichever class you put it in

A Java application needs a main method to start. This is the interface the Java runtime uses to call into your code.


Thank you Paul. I thought, main() is necessary to run the program, so it must me somewhere mentioned in bulit-in classes
 
Campbell Ritchie
Sheriff
Posts: 51453
87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by minal silimkar:
Originally posted by Paul Sturrock


Thank you Paul. I thought, main() is necessary to run the program, so it must me somewhere mentioned in built-in classes
No, none of the built-in classes has a main method, because none of the built-in classes is designed as the starting point for an application. You write a class which starts off your application, and you write a main method for the JVM to start with.
 
Minal Silimkar-Urankar
Ranch Hand
Posts: 136
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Campbell Ritchie

No, none of the built-in classes has a main method, because none of the built-in classes is designed as the starting point for an application. You write a class which starts off your application, and you write a main method for the JVM to start with.


Thank you Campbell, for detailed explaination.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic