Jump to content

Instance variable

From Wikipedia, the free encyclopedia

This is an old revision of this page, as edited by ReigneBOT (talk | contribs) at 16:57, 22 March 2010 (robot Adding: es:Variable de instancia). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

In object-oriented programming with classes, an instance variable is a variable defined in a class (i.e. a member variable), for which each object in the class has a separate copy.

An instance variable is the opposite of class variable, and it is a special type of instance member. An example of an instance variable is "private double length"

Instance Variables (Non-Static Fields) Technically speaking, are objects stored in individual states in "non-static fields", that is, fields declared without the static keyword. Non-static fields are also known as instance variables because their values are unique to each instance of a class (to each object, in other words); the currentSpeed of one bicycle is independent from the currentSpeed of another.