I like to know why only void return type for main method in java.
public static void main(String [] args)
Why there is no other return types other than void for main method.
Thanks
The short answer is: Because that's what the language specification says.
In today's commonly used operating systems (Windows and Unix families), the only "return value" from a process is an exit status, which is a small number (usually 8-bit). This value can be returned from a Java program using the System.exit(int) method:
System.exit(int)
public static void exit(int status) Terminates the currently running Java Virtual Machine. The argument serves as a status code; by convention, a nonzero status code indicates abnormal termination.
public static void exit(int status)
Terminates the currently running Java Virtual Machine. The argument serves as a status code; by convention, a nonzero status code indicates abnormal termination.
2.1m questions
2.1m answers
60 comments
57.0k users