This is a Java Program to Print any Statement Without Using the Main Method.
We put the statement to be printed in a static block. The static block executes before main method hence we get the desired output. But in case of JDK7 the code would not execute as it looks for main method before any other thing.
Here is the source code of the Java Program to print any Statement Without Using the Main Method. The Java program is successfully compiled and run on a Windows system. The program output is also shown below.
public class Without_Main
//Does not work with JDK7
$ javac Without_Main.java
$ java Without_Main