Multiple main() methods in java

Any Java program can contain more than two main methods or any two methods identified by similar names. Consider the following example :

class multipleMain {
	public static void main(String args[]) {
		System.out.println("hello 1");
	}
}

// another class may have same name method that is used in another class
class multipleMain2 {
	public static void main(String args[]) {
		System.out.println("hello 2");
	}
}

The above program compiled as usual :

D:\>javac multipleMain.java

When we want to run first class main method we use :

D:\>java multipleMain
hello 1

When we want to run 2nd class main method we use :

D:\>java multipleMain2
hello 2