Algorithms and Data Structures
Quick Links
What's New 
Home 
Contacts 
Course Book 
Java Book 
JDK & JDSL 
Slides 
Notes 
Demos 
Exercises 
Marks
 
Using the generic List to process a list of integers 
 
We now do a retrofit and implement a list of integers using the generic class List of objects. Here, every object in the list is an Integer, so we read an integer from the keyboard and then construct a new Integer object. 

We also need to define classes for comparing Integer objects so that we can insert into the list in order, and for testing Integer objects (for deletion). See IntComp.java to see the integer comparator, and IntPred.java to see the predicate for testing if an integer object equals a given integer value. 

I have used exactly the same definition of List, and have just copied it over. I should put it in a package, but that's another exercise.. 

Look at the code for the Test.java and compare it to the previous exercise using ToDo lists


Here's all the code 


Copyright © Patrick Prosser 1999.