Arrays

Now that you have an understanding of the primitive types, let's turn our attention to one of the reference types. Recall the three reference types in Java:

  • Classes

  • Interfaces

  • Arrays

Classes and interfaces are complex enough to earn their own chapters, but arrays are comparatively simple, so they are covered here with the primitive types.

An array is simply a way to maintain a sequence of items. Arrays are objects that hold a fixed number of variables of the same type. Arrays can hold primitive types, other objects, or even references to other arrays. If you have data that can be easily indexed and the number of data elements is known in advance, you should definitely consider using an array. Alternatives to arrays are described in Chapter ...

Get Special Edition Using Java 2 Standard Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.