In the previous release of Java, we can have Static Initalizers as an alternative:
public class MainMethodDemo
{
static
{
System.out.println("Static Initalizer");
System.exit(0);
}
}
Output: (From JDK 7)
Error: Main method not found in class Test, please define the main method as:
public static void main(String[] args)
or a JavaFX application class must extend javafx.application.Application
Output: (JDK 6)
Static Initalizer
Interview Questions
Java
Java Tutorial
main() Method
Comments
Post a Comment