Java Methods

In Java, the word method refers to the same kind of thing that the word function is used for in other languages. Specifically, a method is a function that belongs to a class. In Java, every function belongs to a class.

A function is a reusable portion of a program, sometimes called a procedure or subroutine.

Why write and use functions?

With methods (functions), there are 2 major points of view


Using Methods

A special use of import for static methods


Building Methods

Method Examples

Scope of Identifiers

void methods and empty parameter lists


Functions and the compiler


Pass By Value

Example


Method Overloading

Ambiguous Invocation