java return statement code example
Example 1: java return if
public void test(){
if(something){
return;//this ends the method
}
//do whatever you want
}
Example 2: how to create a function that returns in java
// a method for computing the area of the rectangle
public int getArea() {
return width * height;
}
Example 3: return statement in java
A return statement causes the program control to transfer back to the caller of a method.