Q 1. Can we write a java class with : public static int main(String[] args){
Yes, you can but you can't run that Java class.
Example class:
class MainTest {
public static int main(String[] args) {
return 1;
}
}
You will receive an error message when trying to run it:
Error: Main method must return a value of type void in class MainTest, please
define the main method as:
public static void main(String[] args)
Q 2: Next question I unable to answer. He asked write a program so
that your java main method could return something.
You can use System#exit(int) to quit your program with a specific exit code which can be interpreted by the operating system.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…