Hi,
I have a small problem while creating program. This might be a silly question as I am fresher in JAVA. I want to ask that is it possible to run any program in java which have not main method. Like we can run some program in c and c++ which doesent have main method. Is it possible in java.
Thanks.
Hi awadhendra,
You can use static block to perform this task and at the end of statements called System.exit(0) to avoid to generate an exception.
class MainMethodNot { static { System.out.println("This java program have run without the run method"); System.exit(0); } }