Is the main method compulsory in Java? code example
Example: Is the main method compulsory in Java?
// Java Program to demonstrate till Java JDK5 version
// without main() method is possible.
class WithoutMainMethod {
static {
int i = 2, j = 4, sum;
sum = i + j;
System.out.println("The sum of i and j is :" + sum);
System.out.println("This program is without main() valid till JDK 5 version");
}
}