【发布时间】:2012-11-10 13:37:34
【问题描述】:
可能重复:
Where and why JVM checks that the return type of entry method main(String args[]) is void and not anything else?
return type of main in java
在咨询了What's the meaning of the return value of int main(), and how to display it?&What should main() return in C and C++?这两个问题后,我想出了另一个问题:
为什么Java程序的main方法应该返回void,而C/C++程序的main函数应该返回int?
【问题讨论】:
-
简单地说,Java 程序不会因为
main方法(在主线程上运行)结束而结束。 当所有线程结束时结束。所以main的返回值没有意义。
标签: java