Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

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");
}
}
Source by programmersacademy.in #
 
PREVIOUS NEXT
Tagged: #Is #main #method #compulsory
ADD COMMENT
Topic
Name
3+1 =