Main method is the only entry point of the java console application.
Normally we used only one main method in our program.
A java application can have multiple main methods.
Code: -
// myclass.java
class test
{
public static void main(String args[])
{
System.out.println("Main of test class...");
}
}
public class Myclass
{
public static void main(String args[])
{
String str[]={"A","B","C"};
test.main(str);
}
}
In the above example, program starts from Myclass.
For invoking a main method it require a command line arguments also. So that we declared and initialized str[] and passed it to the test.main(str);
Normally we used only one main method in our program.
A java application can have multiple main methods.
Code: -
// myclass.java
class test
{
public static void main(String args[])
{
System.out.println("Main of test class...");
}
}
public class Myclass
{
public static void main(String args[])
{
String str[]={"A","B","C"};
test.main(str);
}
}
In the above example, program starts from Myclass.
For invoking a main method it require a command line arguments also. So that we declared and initialized str[] and passed it to the test.main(str);
Comments
Post a Comment