Suggested Projects


Skill-Building Exercises

  1. Reasoning About Design:   Given the special treatment of String objects in the Java environment, why do you suppose Ashmore’s simple hash code algorithm works?

  2. Creating Different Comparators:   Create several different Comparator classes that can be used to sort Person objects by last name and birthday.

  3. Testing The hashCode() Method:   Write a short program that generates ten thousand logically equal Person objects and see if their hash codes are the same.

  4. Bloch’s Hash Code Algorithm:   Implement Bloch’s hash code algorithm in the body the Person hashCode() method and repeat skill-building exercise 3 above.

  5. Reasoning About Design:   What effects, if any, would different implementations of the Person.toString() method have on the performance of the Person.compareTo() method?

  6. Apples And Oranges:   Create an array of Strings with element values of “1”, “2”, “3”, “9”, “10”, “18”, “22”, “34”. Next, create an array of integers (primitive type ints) and populate the array with the following element values: 1, 2, 3, 9, 10, 18, 22, 34. Sort both arrays using the Arrays.sort() method and explain the results.

  7. Generic Methods:   Convert the Person.equals(), Person.clone(), and Person.compareTo() methods to Java 5 generic methods.

  8. Generic Class:   Convert the PersonAgeComparator class to a Java 5 generic class that operates on Person class objects or subtypes.




Java For Artists(c) The Art, Philosophy, and Science of Object-Oriented Programming
Java For Artists: The Art, Philosophy, And Science Of Object-Oriented Programming
ISBN: 1932504052
EAN: 2147483647
Year: 2007
Pages: 452

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net