Can we execute a program without main() method
//This is prior to Java 7
class StaticInitializationBlock{
static{
System.out.println("class without a main method");
System.exit(0);
}
}
0
0
Yes, one of the ways to execute the program without the main method is
using static block
What if the static modifier is removed from the signature of the main method??
Program compiles. However, at runtime, It throws an error "NoSuchMethodError
Thank you!
0
0
Are there any code examples left?
New code examples in category Other