Introduction
A method is a named block that can be called, and where program execution can continue. Other names for methods in non-object-oriented languages are functions and procedures. But unlike functions and procedures, methods are also members of a class.
The main method is a method that serves as a starting point for program execution. The main method is called automatically when program execution begins. You will get a runtime error if this method is missing.
Program
1 package sharingjava; 2 3 public class Example { 4 5 public static void main(String[] args) { 6 System.out.println("Hello World!"); 7 } 8 9 }
Discussion
One more thing... It's impossible to know that your program need the main method just by examining the grammar. You will not find it there.
0 comments:
Post a Comment