问题描述
在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()
中,我无法使用这些宏.
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?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!