Win a copy of The Java Performance Companion this week in the Performance forum!
    Bookmark Topic Watch Topic
  • New Topic

Can a JAVA program run without a main method()?

 
Hari Dhanakoti
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Report post to moderator
Here is the piece of code which runs without a main function.
Help me in this problem

class EndNow
{
public void p()
{
System.out.println("It also........");
}

}

class MainLess
{
static
{
System.out.println("hi it worked ");
EndNow e = new EndNow();
e.p();
System.exit(0);
}
}
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Report post to moderator
Please stop asking the same question in different forums. Continue the conversation there :
http://www.coderanch.com/t/407561/java/java/Do-Java-program-run-without
 
    Bookmark Topic Watch Topic
  • New Topic