return Statement in Java


☞It is applied at the end of a method.

No statement in the method can be executed after the return statement.

{
    int s=0;
    s=m+n;
    return(s);
    p=m-n;
}

It can only return a single value from a method to its caller.

{
    int s=0,p=0;
    s=m+n;
    p=m-n;
    return(s,p);
}

A function may have more than one termination points.

{
    if(a>b)
        return a;
    else
        return b;
}

It is illegal to use multiple return statements in a function.

{
    int s=0;
    int p=0;
    s=m+n;
    p=m-n;
    return(s);
    return(p); 
}