Hi friends,
As we know that , if we declare user define method as static, then there is no need to create object of class.
We can call method with the help of class name.
Syntax for calling the static method: CLASSNAME.METHODNAME().
Similarly, The main method of java is call by CLASSNAME with the help of JVM.
For Example.
Class Hello
{
static void display();
{
System.out.print("Static method call by Hello");
}
}
Class MainClass
{
public static void main()
{
System.out.print("main method");
}
}
In the above example, JVM call the main method by classname in which main method is declared.
Internally, JVM invokes main() by "MainClass.main()".
0 Comment(s)