| The Java Course provides a general introduction to programming in Java . It is based on A.B. Downey's book, How to Think Like a Computer Scientist. Click here for details. |

Home Arrays of Objects The printDeck method |
||
The printDeck methodWhenever you are working with arrays, it is convenient to have a method that will print the contents of the array. We have seen the pattern for traversing an array several times, so the following method should be familiar: for (int i=0; i<deck.length; i++) { printCard (deck[i]); } } Since deck has type Card[], an element of deck has type Card. Therefore, deck[i] is a legal argument for printCard.
|
||