Java Reference
In-Depth Information
6
Arrays
6.1 INTRODUCTION TO ARRAYS
346
Creating and Accessing Arrays 347
The
length
Instance Variable 350
Initializing Arrays 353
6.4 MULTIDIMENSIONAL ARRAYS
399
Multidimensional Array Basics 399
Using the
length
Instance Variable 402
Ragged Arrays
403
Multidimensional Array Parameters and Returned
Values 403
Example: A Grade Book Class 404
★
6.2 ARRAYS AND REFERENCES
356
Arrays Are Objects 356
Array Parameters 358
Arguments for the Method
main
★
365
Methods that Return an Array 367
6.3 PROGRAMMING WITH ARRAYS
368
Partially Filled Arrays 369
Example: A Class for Partially Filled Arrays 372
The “for-each” Loop
376
Methods with a Variable Number
of Parameters
★
380
Example: A String Processing Example
★
383
Privacy Leaks with Array Instance Variables 384
Enumerated Types
★
386
Example: Sorting an Array 388
★
Chapter Summary 410
Answers to Self-Test Exercises 411
Programming Projects 418