日期:2014-05-20  浏览次数:20709 次

如何编译没有main的java
如何编译没有
main
的java

------解决方案--------------------
直接用javac编译就可以了,只有运行程序时才要求有main()。
------解决方案--------------------
public class Test
{
static
{
System.out.println( "There is only a static block ,rather than a main method ");
}
}
唯一的缺陷就是会抛出exception