What is the significance of the return statement inside a method whose return type is void .
For example see this below program (I cant paste my companys code so i pasted some sample )
public class Pavan {
public static void main(String args[]) {
Pavan r = new Pavan ();
r.kiran();
}
public void kiran() {
int a = 10;
if (a == 10) {
return;
}
System.out.println("Hi I am Kiran");
}
}
It returns from the method invocation, i.e. it doesn’t run any more statements after the return.
An alternative and equivalent way to write your method
kiranwould be this: