A variable defined in a Class, for which each object of the class has its own copy.
For example in this Class:
public class Rectangle
{
private int width;
private int height;
public Rectangle(int w, int h)
{
width = w;
height = h;
}
}
width
and height
are instance variables. Every Rectangle object that gets constructed gets its own width
and its own height
.