I keep getting this question asked by my friends
Write a program to print “Hello,World” without using main() function in java
So my question is:
Is it really possible to write and compile a program without main() without exception.?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Will print
Hello,World, with a pre-1.7 Java VM. Oracle JDK 1.7 checks for amainbefore initializing the class.The JLS Execution part 12.1.4 seems to indicate that the JVM will attempt to run a
mainmethod, but only after initializers have run. This appears to be interpreted differently in Java 1.7.Special thanks to Ted Hopp for the
System.exit(0)line.