Java Reference

Java Reference Home | Smart Soft Home

return

Description

Used to ubrubtly exit a method thus returning control back to the calling method. And, optionally, to return a value back to the calling method.

Example 1: No Value Returned

void myMeth(){
  ..
  if (x==10) return;
  ..
}

Example 2: Value Returned

int getCube(int x){
  return x*x*x;
}