PART I
C h a p t e r 1 0 :
I n d e x e r s a n d P r o p e r t i e s
267
PART IPART I
As the output verifies, objects of type
RangeArray
can be indexed in ways other than
starting at zero. Let’s look more closely at how
RangeArray
is implemented.
RangeArray
begins by defining the following private instance variables:
// Private data.
int[] a; // reference to underlying array
int lowerBound; // smallest index
int upperBound; // largest index
The underlying array is referred to by
a
. This array is allocated by the
RangeArray
constructor. The index of the lower bound of the array is stored in
lowerBound
, and the
index of the upper bound is stored in
upperBound
.
Next, the auto-implemented, read-only properties
Do'stlaringiz bilan baham: |