How to create method and how to call it? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How to create method and how to call it?

10th Dec 2016, 4:10 PM
raj
raj - avatar
2 Answers
+ 2
Learn all the lesson in Java Course, and you will know how to do it.
11th Dec 2016, 12:11 AM
The PGDeveloper
The PGDeveloper - avatar
+ 1
method is like public int sum(int x){ return ++x; } in the same class or another one, to call it, if it's in the same class type: sum(any number to do summation); if it's in another class, u have to create an object anotherclass object = new anotherclass; then call like this object.sum(any number) ;
10th Dec 2016, 4:27 PM
Salim Ali Alsenani
Salim Ali Alsenani - avatar