0
Why we will not write return in void main ??
2 Answers
+ 1
As a matter of fact we could use return with void methods, but with no returned value
See ex: in below
public class Program
{
public static void main(String[] args) {
showPositive(9);// prints 9
showPositive(-5);// prints nothing
}
public static void showPositive(int i){
if(i<0) {
return;
}
System.out.println("i=" + i);
}
}
0
Because main returns no value. Where would you want to return a value to?