0
Explain about using method (return) in java?
Need this topic to solve assignment questions
2 Answers
0
A method is a piece of reusable code. It might return a value (of a type that is declared in its signature) which you can store in a variable e.g.
String s = myMethod(param)
where param is an input that may affect what is returned.
A method with a void return type doesn't return anything, and can't be assigned to a variable. It can still do stuff, but that's all.
You might think of an ATM. I can withdraw some cash (returning an int of money or perhaps a Currency object) or I can request to see my balance (void return type, I'm not getting anything, but the ATM is doing something - printing information to the screen)
0
@Dan Walker thank u for info