0
Still not sure what method is .. i need a simple explanation ?
4 Réponses
+ 6
method is function which belongs to class. Function is a part of code which you can call when you need it. For example:
lets say that you have class called "MagicNumber" which contain random int value and three methods. You can check if number is lower, or higher, or equal 0
if (MagicNumber.value > 0 ){
MagicNumber.behaveWhenHigher() }
else if (MagicNumber.value < 0 ){
MagicNumber.behaveWhenLower() }
else {
MagicNumber.behaveWhenZero() }
I hope it can help you ;)
cheers
+ 1
method is another name for function in java and it simply defines how are our requirements can be fulfilled by writing some instructions.
0
a method is an instruction or set of instructions to run.
0
Method in java is similar to functions in c++.