User defined methods in java

Methods with parameter and with return type

The above method consists of two parameters and it doesn’t return any value so there is a return type void. The number of parameters and its types can be any as per the requirement. The static keyword is used because I’ve called this method from static main method (you will see below in complete code). If you’re calling the method from non-static method then, no need to use static keyword.