Java MethodsLesson 20Free preview
Java Methods
This lesson is part of Java · All levels
Summary
A method is a set of statements named to perform a particular task, so that the code is more orderly and not repetitive. A method is created with the syntax `returnType methodName()` and then called through `methodName()`. There are methods that do not return values with void type, and some return results through the return statement.
Key points
- The method is defined in a class and called by writing its name and parentheses
- The void type means the method does not return any value
- The non-void method must return the declared value according to the declared type
- Static method is called by ClassName.method(), object methods by `namaObjek.method()`
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.