> return statement in java ~ Online tutorial

return statement in java

 return statement

returns control to the invoker of a method or constructor .
ReturnStatement:

return Expressionopt ;
  • A return statement with no Expression must be contained in the body of a
    method that is declared, using the keyword void, not to return any value , or
    in the body of a constructor .
  • A compile-time error occurs if a return statement appears within an instance initializer or a static initializer .
  • A return
    statement with no Expression attempts to transfer control to the invoker of the
    method or constructor that contains it.
  • To be precise, a return statement with no Expression always completes
    abruptly, the reason being a return with no value.
  • A return statement with an Expression must be contained in a method declaration
    that is declared to return a value or a compile-time error occurs.
  • The
    Expression must denote a variable or value of some type T, or a compile-time
    error occurs.
  • The type T must be assignable to the declared result type of
    the method, or a compile-time error occurs.

Buy It now




Please Give Us Your 1 Minute In Sharing This Post!
Please Give Us Your 1 Minute In Sharing This Post!
SOCIALIZE IT →
FOLLOW US →
SHARE IT →
Powered By: BloggerYard.Com

0 comments: