0

Explain methods in java

java

21st Aug 2018, 4:49 AM
Randy Ranji
3 Answers
21st Aug 2018, 5:02 AM
Hatsy Rei
Hatsy Rei - avatar
+ 1
methods in Java are like functions in other languages like C++. they take parameters (or arguments), there is some code or operation on the parameter, and it may or may not return a value. if it returns a value then the code must not be void.
21st Aug 2018, 6:27 AM
H U
H U - avatar
+ 1
A method is a collection of statements that perform some specific task and return result to the caller. A method can perform some specific task without returning anything. Methods allow us to reuse the code without retyping the code. In Java, every method must be part of some class which is different from languages like C, C++ and Python. Methods are time savers and help us to reuse the code without retyping the code.
21st Aug 2018, 11:52 AM
Maninder $ingh
Maninder $ingh - avatar