File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

main()

 
Sanjay Izardar
Greenhorn
Posts: 19
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
where the main() is defined.
and what is the use of static keyword in public static void main(String argument[])
 
Aditi agarwal
Ranch Hand
Posts: 225
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
main is used in that class from which you want your project or file to be started


More over we use the STATIC keyword to call the Main() without creating the object by JVM
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Pie
Posts: 15150
31
Android IntelliJ IDE Java Scala Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You define the main() method yourself, in whatever class you like. When you start a Java program, Java will look for a public static void main(String[] args) method - that's where your program starts running, as Aditi already mentioned.

For the meaning of "static", see this tutorial page: Understanding Instance and Class Members.
 
Mittal Vishal
Greenhorn
Posts: 21
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Static methods are known as class methods. They belong to the class in which they are declared, and are not part of any instance of the class.
So to invoke them, object of the class is not required.
That's why main method is declared as static so that JVM can invoke it
 
Nico Van Brandt
Ranch Hand
Posts: 66
Eclipse IDE Firefox Browser Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Note that both are correct:
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic