Whether Class Contains Main Method
Whether Class Contains Main Method
the above syntax is very strict and if we perform any change then we will get
runtime exeception saying no such method error:main
even though above syntax is very strict the following changes are acceptable
1.insted of public static we can take static public i.e the order of modifiers is
not importent
2.we can declare string array in any acceptable form
main(string [] args)
main(string []args)
main(string args[])
3.instead of args we can take any valid java identifier
ex:main(string durga)
4.we can replace string[] with var-org parameter
main(String...args)
class Test
{
public static void main(String args[]){
System.out.print("string[]");
}
oublic static void main(int[] args){
System.Out.Print("int[]");
}
}
o/p==>string[]
overloading of the main method is possible but jvm will always call string array
orgument main method ob=nly other overloaded method we have to call explicitlylike
normal method call