Part 13 – Java Methods (Introduction)
July 29, 2020 1 min read

Introduction:
If you want to use a code again and again repeatedly you can write the code in a method and call it in the main method. There are 3 types of java methods. Let’s see what are those methods.
Method I (Non-parameterized)

Here the method name is “printAddress()”. You can write any code inside the method. But you should call the method in the main method, because compiler runs the main method. That statement is called “method calling statement”.
Method II (Parameterized)

We can write a method by giving a parameter also. Here the “String ad” is the parameter. But when you calling it in the main method, you should give values to the parameterized method. That value is known as “method argument”. And the argument should be in the same data type you used in the parameter.
Method III (Return type)

In this method type, you can use a return type instead of “void” as shown in the above example. Here we used int. And keep in mind when you create a return type method you should return the value. It also should be in the same data type used for the return type. And the return statement should be always the last statement in a return type method. According to the above example, 30 will become as the output.
Those are the 3 types of java methods that helps to reuse a code without retyping the code.
we’ ll meet in the next article with the 2nd part of java methods. See you soon.
Thank you.


