Arrays
Now that we have a model for a playing card, how do we model a deck of cards? Java offers arrays, which are collections of a given type, where each element in the collection is numbered consecutively. You can make an array of any type. Figure An int array shows a picture of an int array:

Figure A char array shows picture of a char array:

Figure An array of TicTacToeSquare values shows an array of the Tic Tac Toe game's TicTacToeSquare enumerated type:

And Figure A Card array shows a picture of a Card array. Note that each element of the array contains a Card.

Each figure above shows how an array's elements are numbered, or indexed. The first element has index 0; the last element has an index that is 1 less than the length of the array. (This can take some getting use to.)
Unlike a class type or an enumerated type, an array type does not require a type declaration: you create an array type by simply appending “[]” to another type—even another array type. An int array is simply int[]; a char array is char[]; a TicTacToeSquare array is TicTacToeSquare[]; a Card array is Card[].
Once created, a Java array cannot be lengthened or shortened. So while they are great for many things, arrays are not great for modeling collections that grow and shrink, which you will find is the case for many collections in games. But arrays will serve for now. We will get to extendible collections later in the text.
Two-dimensional arrays
… there aren't any. Java only has one-dimensional arrays. But recall that you can make an array of any type, so you can make an array of arrays. In fact, you can make an array of arrays of arrays. This is how you might model a Tic Tac Toe board:
TicTacToeSquare[][]
Conceptually, this model would look like this:

You, the programmer, are responsible for mapping your game's concepts of rows and columns to your data model's array of arrays. The figure above shows what a Tic Tac Toe board looks like as an array of arrays, but it's entirely up to you whether the inner arrays represent the rows or the columns. This is a choice you make at the beginning of coding your game, and then you just need to keep it straight in your head, and document your choice in your code.