Introduction Edit

Method Example Program

An example program of method usage.

In object-oriented programming, a method is a subroutine that is exclusively associated either with a class (called class methods or static methods) or with an object (called instance methods). Like a procedure in procedural programming languages, a method usually consists of a sequence of statements to perform an action, a set of input parameters to customize those actions, and possibly an output value (called the return value) of some kind. Methods can provide a mechanism for accessing (for both reading and writing) the encapsulated data stored in an object or a class. Java Applets

Static Methods Edit

Static Method Example

An example program of static method usage.

A method may be declared as static, meaning that it acts at the class level rather than at the instance level. Therefore, a static method cannot refer to a specific instance of the class (i.e. it cannot refer to this, self, Me, etc.), unless such references are made through a parameter referencing an instance of the class, although in such cases they must be accessed through the parameter's identifier instead of this.

See Also Edit

Links Edit

Wikipedia Definition

Smallwikipedialogo.png This page uses content from Wikipedia. The original article was at Method (computer science). The list of authors can be seen in the page history. As with Java Wiki, the text of Wikipedia is available under the GNU Free Documentation License.


Community content is available under CC-BY-SA unless otherwise noted.