Skip to content
Anthony Christe edited this page Sep 19, 2013 · 3 revisions

Creating a Generic Class

  • Create a generic class "ThreeItemBox" that only accepts types that extend "Comparable"
  • Create three generic instance variables first, second, and third
  • Create a constructor which takes three generic variables and assigns them to first, second, and third
  • Create generic getters and setters for first, second, and third
  • Create a generic method "getSortedItems" which returns an ArrayList of the first, second, and third in sorted order (can use Collections.sort or compareTo).

To test your code

  • Create a ThreeItemBox for Integers, Doubles, and String with the following values passed to the constructor
  • Integers: 9, 5, 1
  • Doubles: 8.5, 100.0, 2.0
  • Strings: "poke", "ono", "ahi"
  • Print out the results of getSortedArrayList for each instance

Comparing and Contrasting Lists

  • Pros/cons of array based list vs node based list

Compare and contrast the following methods for Linked List, Doubly Linked List, and Circular Linked List. Consider Big-O runtime. Which list provides better performance for each method? Why?

  • Add front/end
  • Adding somewhere in the middle of the list
  • Removing from front/end
  • Removing from middle
  • Searching through list

Clone this wiki locally