CS 1054: Lab 8

Lab meeting 8: Sorting Example

Note

For this lab you can work with a partner.

Aim

The main aim of this lab is to introduce you to the concept of sorting a list of Objects.

 

List of tasks

For this lab you will implement just one class: Sorter. I will let you decide what code to put in the class. You will create an arraylist that will store Integer objects (note Integer objects are different than the primitive data type "ints"). Add about 10 Integer objects. You can  add objects representing the ints: 10, 12, 11, 8, 9, 13, 12, 15, 89, 90. Once you add objects to the arrayList, now sort the arrayList from ascending to descending order. The order of the objects after sorting will be: 8, 9, 10, 11, 12, 12, 13, 15, 89, 90.

The classes you will need to refer are: Integer class, Collection class, and the ArrayList class.  http://java.sun.com/j2se/1.5.0/docs/api/

Please document your code.

Absolutely Necessary!

Some helpful Links

int to Integer conversions http://mindprod.com/jgloss/intvsinteger.html

I will let you search how to sort a collection in java.

 


© Mir Farooq Ali 2003.