4

和有什么区别

Runtime.exit(0) 和 System.exit(0)

同样之间有什么区别

Runtime.gc() 和 System.gc()

什么时候用哪个?

4

4 回答 4

2

System.Xxxx 更短。Runtime.Xxxx() 不能直接使用。

于 2012-04-25T10:24:33.150 回答
2

和有什么区别

Runtime.exit(0) and System.exit(0)

没有任何。

同样之间有什么区别

Runtime.gc() and System.gc()

没有任何。

什么时候用哪个?

由于没有区别,因此选择纯粹是装饰性的。

于 2012-04-25T10:50:16.477 回答
1

看看javadocs:http ://docs.oracle.com/javase/1.5.0/docs/api/java/lang/System.html#exit(int )

“调用 System.exit(n) 实际上等同于调用:Runtime.getRuntime().exit(n)”

于 2012-04-25T10:24:03.480 回答
0

没有,它们是一样的。

http://docs.oracle.com/javase/7/docs/api/java/lang/System.html

于 2012-04-25T10:25:08.707 回答