+ 1
What happens.when we write "public static int main (String args [])" instead of "void main" in java
5 Answers
+ 3
You get a compile time error that says you must return type void from main method
+ 1
But why it should always return null value
+ 1
Aadarsh Gupta actually when using the "void" keyword nothing at all is returned, control is just restored to the main program that invoked our method, in this case the operating system.
+ 1
So there is any way to return a value other than null
+ 1
Aadarsh Gupta Not from the "main" method however if you write your own methods that you call within the "main" method you can return any datatype from them that you need to.