Methods in Java

A method is a self-contained block of statements or a sub-program of one or more statements that performs a special task when it is called. We can directly pass data in a method called parameters as a passing value. In Java, methods are used to perform certain specific actions and they are also known as functions.