Quote:
Originally Posted by greeninho
If I understand your question 'why use return in some methods?'.
You only use 'return' when your method is declared with any of java primitive types.
Remember the format for declaring method:
accessModifier type methodName(parameters)
{
statements;
}
'void' is a type that doesnt return anything,so it doesnt use return.
E.g:
Consider me(int) sending you(statements) to the market, when you return, you must give me a feedback(return statement).
|
My question was: what's a "return val" statement for? Did you have a look at my last code in previous post? There is no return statement, but I still get a proper feedback from method - I obtained calculated value of "i" variable without returning it. I just invoked it.