0
What is the method in Java
4 Réponses
+ 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
+ 3
K. Pradeep
Did you understand class?
+ 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();