Why do we use return in Java?
I'll answer
Earn 20 gold coins for an accepted answer.20
Earn 20 gold coins for an accepted answer.
40more
40more
Studied at the University of Amsterdam, Lives in Amsterdam, Netherlands.
It does not need to contain a return statement, but it may do so. In such a case, a return statement can be used to branch out of a control flow block and exit the method and is simply used like this: return; If you try to return a value from a method that is declared void , you will get a compiler error.
2023-05-14 14:09:53
评论(499)
Helpful(122)
Helpful
Helpful(2)

Mia Walker
QuesHub.com delivers expert answers and knowledge to you.
It does not need to contain a return statement, but it may do so. In such a case, a return statement can be used to branch out of a control flow block and exit the method and is simply used like this: return; If you try to return a value from a method that is declared void , you will get a compiler error.