• Learn how to create and use a rectangular array.
• Learn about ragged arrays of any dimension.
Two-dimensional tables and the mathematical matrix can be implemented using
rectangular arrays. However, although we may abstractly think in terms of a rec-
tangular array, Java implements it in a way that allows rows of a rectangular array
to have different lengths, giving us the so-called ragged array . In this chapter, we
use what you have already learned about arrays in the previous chapter to show
how to create and manipulate ragged arrays.
Consider the following declaration and assignment statement:
int  b;
b= new int ;
These differ from the declaration and assignment for a one-dimensional array in
that there are two pairs of brackets, not one. This means that b contains the name
of a two-dimensional array, or table, and not a one-dimensional array:
2 5 4
1 4 8