What is the method in Java | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

What is the method in Java

22nd Jul 2023, 1:35 PM
K. Pradeep
K. Pradeep - avatar
4 Answers
+ 4
A method is block of code which only runs when it is called for more detail you can see this also: https://www.sololearn.com/learn/Java/2152/?ref=app
22nd Jul 2023, 1:41 PM
Sakshi
Sakshi - avatar
+ 3
K. Pradeep Did you understand class?
22nd Jul 2023, 1:47 PM
A͢J
A͢J - avatar
+ 2
A method is simply a function but referred to a class. A method specifies a behaviour of that class. A method could be non-static or static. Respectively either needs a new instance of a class to be called or not. Let's say we have a method called "hello()". If non-static then: myObject = new myClassObject(...); myObject.hello(); If static then: myClassObject.hello();
23rd Jul 2023, 7:57 AM
Gabriele Gatti
Gabriele Gatti - avatar