退出主要功能 [英] exiting functions in main

查看:217
本文介绍了退出主要功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对Stackoverflow和Java相对比较新,但我对C有一点经验。在'exit()'函数出现故障后,我喜欢C退出程序的非常干净的方式。

I am relatively new to Stackoverflow and Java, but I have a little experience in C. I liked the very clean way of C exiting the programs after a malfunction with the 'exit()' function.

我在Java中发现了一个类似的函数System.exit(),它与C函数有什么不同,什么时候应该使用'System.exit()'而不是简单的'return'in Java类似于void main函数?

I found a similar function System.exit() in Java, what differs from the C function and when should I use a 'System.exit()' best instead of a simple 'return' in Java like in a void main function?

推荐答案

System.exit()将终止为此程序启动的jvm,其中 return; 只是将当前方法的控件返回给调用者

System.exit() will terminate the jvm initilized for this program, where return; just returns the control from current method back to caller

另见

  • when-should-we-call-system-exit-in-java ?

这篇关于退出主要功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆