0

what return when main method becomes static void

what become void

23rd Nov 2016, 8:55 AM
rajan kumar gupta
rajan kumar gupta - avatar
2 odpowiedzi
+ 1
main method doesn't return any value, because its return type is void. if the main method is not void the program do not start
23rd Nov 2016, 9:06 AM
Simone Novaro
Simone Novaro - avatar
0
If the return type of a method is 'void' then - answering to "what (to) return" - you return nothing, as said above by Simone. If you want to exit in the middle of the method, because job is done, then use 'return' without any further arguments: void someMethod() { //do something if (/*job is done*/) { return; } //do stuff }
23rd Nov 2016, 2:38 PM
Magyar Dávid
Magyar Dávid - avatar