Can we use return in main method??

Instead of using return type void in Java why not it works with return type int and return 0 as per line of code this thing happens in c++ but I tried in Java this doesn't work here

7/15/2019 2:50:49 PM

Nishant Singh

2 Answers

New Answer


One answer Java is not C++ ! Though both languages have some similarities.


Java only recognizes the main method if it has a void return type.