Methods or functions are the main building blocks of Java programs. They can be called several times in the same program, allowing the code to be reused. A Java method is a collection of statements that is grouped together to perform an operation. A function exists in three different forms within a program: method prototype, method definition and method call. A function is accessed by providing the method name along with the argument list enclosed in the parenthesis. A parameter is a value that is passed to a method. The values passed to the method during its call from the caller are called arguments. Arguments to a function can be primitive data types and reference data types.
There are two types of parameters - actual parameters and formal parameters. The parameters that appear in function call statement are called actual parameters. The parameters that appear in method definition are called formal parameters. There are two ways for passing argument to the method - call by value and call by reference. In call by value, in place of passing a reference, a copy of the actual argument is passed to the method. In call by reference, in place of passing a value, a reference to the original variable is passed to the method. Arguments passed to main() method are known as command line arguments.