Method types — Java Programming #12
A method can be declared inside a class and can either return a value or not. If a method returns a value, the return type must be…
Method types — Java Programming #12

A method can be declared inside a class and can either return a value or not. If a method returns a value, the return type must be specified in the method declaration, otherwise, the return type is void.
A method is a block of code that performs a specific task or operation. It is a set of instructions that are grouped together and given a name so that they can be called and executed multiple times throughout a program.
A method can be declared inside a class and can either return a value or not. If a method returns a value, the return type must be specified in the method declaration, otherwise, the return type is void.
Methods can also have parameters, which are values that are passed to the method when it is called. These parameters can be used inside the method to perform operations or calculations.
We can divide methods as predefined methods and user-defined methods.
Again we can divide user defined into two categories as Static methods and non-static methods.
Pre-defined/Pre-build methods
a predefined method is a method that is already defined in the Java language or in its standard libraries, which are included with the Java Development Kit (JDK). These methods are also sometimes referred to as built-in methods or library methods.
Predefined methods provide commonly used functionality and can be used by developers without having to write their own implementation. These methods can be used by simply invoking them and passing the appropriate parameters, without needing to understand how they are implemented.
Ex: length(), substring()
User-defined methods
A user-defined method is a method that is defined by the programmer to perform a specific task. Unlike predefined methods, which are part of the Java language or its standard libraries, user-defined methods are created by the programmer to meet the specific requirements of their application.
To define a user-defined method in Java, the programmer must specify a method signature, which includes the method name, the type and order of its parameters (if any), and the method’s return type (if any). The method body contains the statements that define the behavior of the method.
Static method
A static method is a method that belongs to a class rather than to an instance of that class. This means that a static method can be called directly on the class itself, without the need to create an instance of the class first.
Non-static method
A non-static method is a method that belongs to an instance of a class, rather than to the class itself. This means that a non-static method can only be called on an instance of the class, rather than on the class itself.
Non-static methods are typically used to perform operations that are dependent on the state of a particular instance of the class.
Methods can also have parameters, which are values that are passed to the method when it is called. These parameters can be used inside the method to perform operations or calculations.
First of all, let’s see, what is a method ?
메타데이터
- post_id
- f2c2318ed8c2
- slug
- method-types-java-programming-12-f2c2318ed8c2
- url
- https://medium.com/@sinethshashintha2000/method-types-java-programming-12-f2c2318ed8c2
- canonical_url
- https://medium.com/@sinethshashintha2000/method-types-java-programming-12-f2c2318ed8c2
- author_url
- https://medium.com/@sinethshashintha2000
- status
- ok
- fetched_at
- 2026-08-07 03:48:46