New course! Every coder should learn Generative AI!
Try a free lesson0
Can I assign a different return type to main method?
1 Answer
+ 4
No, main should return void.
When main returns something, is often used by command interpreters and other external programs to determine whether the process completed successfully. To achieve the same effect in Java, you can use use the System.exit function.
public static void main(String[] args) {
//some code
System.exit(88); //return a value
}