0

Explain about using method (return) in java?

Need this topic to solve assignment questions

6th Dec 2017, 11:48 AM
wxid_yj6ot86r103522
wxid_yj6ot86r103522 - avatar
2 odpowiedzi
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)
6th Dec 2017, 12:05 PM
Dan Walker
Dan Walker - avatar
0
@Dan Walker thank u for info
6th Dec 2017, 6:05 PM
wxid_yj6ot86r103522
wxid_yj6ot86r103522 - avatar