All about Computer

Saturday, October 28, 2017

Public Static Void main in JAVA

public static void main(String args[]):


public:

  • The main() method in Java called by Java virtual machine that means  a method (main) called from out side of the class. JVM(Java Virtual Machine) not inside the class, not in the same package, not sub class of any class. So clearly Without using  public we can't access main method.
static:

  • JVM calls the main method without creating an object. So if we want to call a method without creating an object we declare that method as static and we call that method using class name.JVM also called main method using class name
  • JVM calls the main as follows
  • ex: classname.main(0);

void:

  • We are all well known about void.It means it doesn't return anything.
public static void main in java

No comments:

Post a Comment