Hands-On Design Patterns with Java
上QQ阅读APP看书,第一时间看更新

Instance variables

In the Bicycle class, we had four instance variables. Refer to the following code snippet for reference:

// instance variable declarations
private int gears = 0;
private double cost = 0.0;
private double weight = 0.0;
private String color = "";

These are instance variables because they exist for every instance of the Bicycle class. In our examples thus far, we only had one instance of Bicycle, but we can have an unlimited amount, each with their own set of these instance variables.