O'Reilly logo

Ivor Horton's Beginning Java™ 2, JDK™ 5th Edition by Ivor Horton

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

14.9. Exercises

You can download the source code for the examples in the book and the solutions to the following exercises from http://www.wrox.com.

  1. Implement a version of the program to calculate prime numbers that you saw in Chapter 4 to use a Vector<> object instead of an array to store the primes. (Hint: Remember the Integer class.)

  2. Write a program to store a deck of 52 cards in a linked list in random sequence using a Random class object. You can represent a card as a two-character string—"1C" for the ace of clubs, "JD" for the jack of diamonds, and so on. Output the cards from the stack as four hands of 13 cards.

  3. Extend the program from this chapter that used a map to store names and telephone numbers such that you can enter a number to retrieve the name.

  4. Implement a phone book so that just a surname can be used to search, and have all the entries corresponding to the name display.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required