Exercises

  1. J.3 Define each of the following terms:

    1. Collection

    2. Collections

    3. Comparator

    4. List

    5. HashMap

    6. ObjectOutputStream

    7. File

    8. ObjectOutputStream

    9. byte-based stream

    10. character-based stream

  2. J.4 Briefly answer the following questions:

    1. What is the primary difference between a Set and a Map?

    2. What happens when you add a primitive type (e.g., double) value to a collection?

    3. Can you print all the elements in a collection without using an Iterator? If yes, how?

  3. J.5 (Duplicate Elimination) Write a program that reads in a series of first names and eliminates duplicates by storing them in a Set. Allow the user to search for a first name.

  4. J.6 (Counting Letters) Modify the program of Fig. J.9 to count the number of occurrences of each letter rather ...

Get Android How to Program, 3/e now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.