can i run a program without main in java, if so write the code for that
Printable View
can i run a program without main in java, if so write the code for that
Question moved to proper forum .
Yes,we can write .
class X
{
static{
System.out.println("This is static block");
public void show(){System.out.println("This is show()");
}
/**u can place System.exit(0); to ignore exception
*/
System.exit(0);
}//static block end here
}