System的exit
来源:互联网 发布:mac迅雷无法下载 编辑:程序博客网 时间:2024/06/05 12:49
System的exit
源码
/** * Terminates the currently running Java Virtual Machine. The * argument serves as a status code; by convention, a nonzero status * code indicates abnormal termination. * <p> * This method calls the <code>exit</code> method in class * <code>Runtime</code>. This method never returns normally. * <p> * The call <code>System.exit(n)</code> is effectively equivalent to * the call: * <blockquote><pre> * Runtime.getRuntime().exit(n) * </pre></blockquote> * * @param status exit status. * @throws SecurityException * if a security manager exists and its <code>checkExit</code> * method doesn't allow exit with the specified status. * @see java.lang.Runtime#exit(int) */ public static void exit(int status) { Runtime.getRuntime().exit(status); }
功 能: 关闭所有文件,终止正在执行的进程。
exit(0):正常运行程序并退出程序;
exit(1):非正常运行导致退出程序;
测试方法:
// 测试方法 public static void main(String[] args) { StackType stackType = new StackType(); try { DATA3 data3 = stackType.PopST(stackType); // 此处调用了 exit 直接关闭了当前现成 之后方法都未执行 }catch (Exception ee){ System.out.printf("sss"); } } DATA3 PopST(StackType s){ if(s.top==0){ System.out.printf("栈为空!"); System.exit(0); System.out.printf("关闭后"); //永远不会执行 } return (s.data[s.top--]); }
控制台输出
Connected to the target VM, address: '127.0.0.1:52564', transport: 'socket'Disconnected from the target VM, address: '127.0.0.1:52564', transport: 'socket'栈为空!Process finished with exit code 0
阅读全文
0 0
- System的exit
- 应该知道的System.exit()
- System.exit()方法的作用
- System.exit()方法的作用
- System.exit()方法的作用
- System.exit(0)与System.exit(1)的区别
- system.exit(0)和system.exit(1)的区别
- System.exit(0)及System.exit(1)的作用
- System.exit(0) 与System.exit(1)的区别。
- System.exit(0)与System.exit(1)的区别
- System.exit(0)和System.exit(1)的区别
- java的System.exit(0)和System.exit(n)
- System.exit(0)和 System.exit(1)的区别
- java的System.exit(0)和System.exit(1)区别。
- System.exit(1)和System.exit(0)的区别
- System.exit(-1)和return 的区别
- system.exit()与return的区别
- System.exit()和return的区别
- jQuery悬浮窗弹出登录注册HTML源码--一天一个界面
- 【51】51单片机接按键时为什么需要上拉电阻?
- Kotlin初识
- [TensorFlow学习手记] 6
- C++模板、预处理、信号处理
- System的exit
- [leetcode] 516. Longest Palindromic Subsequence
- 栈结构
- SketchUp Pro(草图大师)一款简易学的三维模型绘图软件(破解软件、安装教程和部分入门资料可下载)
- 开启Mac自带apache和PHP开发环境
- 东方程序员怎么看西方程序员
- I2C上拉电阻的选择(最小值)
- leetcode解题方案--058--Length of Last Word
- 排序算法的总结(插入排序、冒泡排序、选择排序)