java - The meaning of return; without any value -


i want know difference between instruction return; , return value;, because when use non void function return instruction followed expression, value or local variable containing value.

example:

public int f(a){a=1;return a},public int f(){return 0;} 

but don't understand return followed semi column without value such return ;. help.

you need understand 2 things:

  1. the return statement - 2 things a) terminates method's execution returning point of execution statement after method called, b) provides way of returning value (if method return value)
  2. a void method - method returns nothing

so void method not return write return; terminate. if method returned int return 5; or return myint;.


Comments