Is there a replacement for EXIT_SUCCESS and EXIT_FAILURE in Java?(Java 中是否有 EXIT_SUCCESS 和 EXIT_FAILURE 的替代品?)
问题描述
在 C 程序中,我一般在 exit() 函数中使用 EXIT_SUCCESS 或 EXIT_FAILURE 来提高程序的清晰度和可理解性.
In a C program, I generally use EXIT_SUCCESS or EXIT_FAILURE in exit() function to improve clarity and understandability of the program.
但在 System.exit() 中我无法使用这些 MACROS.
But in System.exit() I couldn't use these MACROS.
我可以将自己的界面定义为
I can define my own interface as
public interface ReturnValues {
public int EXIT_SUCCESS = 0;
public int EXIT_FAILURE = 1;
}
除了我自己的实现,java中还有其他方法可以使用这些宏吗?(例如使用预定义的库类变量或通过实现预定义的接口等)
Other than my own implementation, is there any other way in java to use these Macros? (like using predefined library class variables or by implementing predefined interface etc..)
推荐答案
不,Java 中没有用于 SUCCESS 和 FAILURE 的预定义常量.当然,因为可能存在几种不同类型的故障,具体取决于每个特定的应用程序.
No, there is no predefined constants in Java for SUCCESS and FAILURE. Certainly because there might be several different kinds of failures, depending on each specific application.
这篇关于Java 中是否有 EXIT_SUCCESS 和 EXIT_FAILURE 的替代品?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Java 中是否有 EXIT_SUCCESS 和 EXIT_FAILURE 的替代品?
基础教程推荐
- 控制台应用程序中的 Java 键盘输入解析 2022-01-01
- 将 double 转换为 Int,向下舍入 2022-01-01
- 如何在相机中应用自定义滤镜 [Surfaceview 预览]. 2022-01-01
- doFilter()是在servlet的工作完成之前还是之后执行的? 2022-01-01
- 将 Windows 证书导入 Java 2022-01-01
- 在java中使用xpath和selenium解析HTML表格数据 2022-01-01
- 在springboot中如何给mybatis加拦截器 2023-04-29
- JPA惰性列表上的流 2022-01-01
- Maven:无效的目标版本:10 2022-01-01
- Java ECDSAwithSHA256 签名长度不一致 2022-01-01
