1public class Jacob {
2
3 public static void main(String[] args) {
4 //code here
5 }
6}
7
1public class Test {
2
3public static void main(String[] args){
4
5 System.out.println("Hello World");
6
7}
8}
9
1public class Test {
2
3public static void main(String[] args){
4
5 System.out.println("Hello Luggas");
6
7 }
8}
1Main() method is starting point of execution for all java applications.
2public static void main(String[] args) {}
3
4String args[] are array of string objects we need to pass from command line
5arguments.
6Every Java application must have atleast one main method.
7
8public : “public” is an access specifier which can be used outside the class.
9When main method is declared
10public it means it can be used outside class.
11static : To call a method we require object. Sometimes it may be required
12to call a method without the
13help of object. Then we declare that method as static. JVM calls the main()
14method without creating
15object by declaring keyword static.
16void : void return type is used when a method does’nt return any value .
17main() method does’nt return
18any value, so main() is declared as void.
19