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 的替代品?
基础教程推荐
- 问题http://apache.org/xml/features/xinclude测试日志4j 2 2022-01-01
- 修改 void 函数的输入参数,然后读取 2022-01-01
- 无法复制:“比较方法违反了它的一般约定!" 2022-01-01
- 如何对 Java Hashmap 中的值求和 2022-01-01
- Struts2 URL 无法访问 2022-01-01
- 存储 20 位数字的数据类型 2022-01-01
- RabbitMQ:消息保持“未确认"; 2022-01-01
- Spring AOP错误无法懒惰地为此建议构建thisJoinPoin 2022-09-13
- 使用堆栈算法进行括号/括号匹配 2022-01-01
- REST Web 服务返回 415 - 不支持的媒体类型 2022-01-01
