Main - S LinkedList<Student> sList2 =...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
import java.util.*; i public class Main { public static void main(String[] args) { ArrayList<Student> sList = new ArrayList<Student>(); A sList.add(new Student("1", "Tom", 4.0)); sList.add(new Student("2", "Bob", 3.0)); sList.add(new Student("3", "Jack", 3.5)); sList.add(new Student("4", "Matt", 3.2)); sList.add(new Student("5", "Henry", 4.0)); s Collections.sort(sList); System.out.println("List sorted according to name:"); for (int i = 0; i < sList.size(); i++) System.out.println(sList.get(i).toString()); S Collections.sort(sList, new IdComparator()); System.out.println("\n\nList sorted according to id:"); for (int i = 0; i < sList.size(); i++) System.out.println(sList.get(i).toString());
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: S LinkedList&lt;Student&gt; sList2 = new LinkedList&lt;Student&gt;(); L sList2.add(new Student(&quot;1&quot;, &quot;Tom&quot;, 4.0)); sList2.add(new Student(&quot;2&quot;, &quot;Bob&quot;, 3.0)); sList2.add(new Student(&quot;3&quot;, &quot;Jack&quot;, 3.5)); sList2.add(new Student(&quot;4&quot;, &quot;Matt&quot;, 3.2)); sList2.add(new Student(&quot;5&quot;, &quot;Henry&quot;, 4.0)); s Collections.sort(sList2); System.out.println(&quot;List sorted according to name:&quot;); for (int i = 0; i &lt; sList2.size(); i++) System.out.println(sList2.get(i).toString()); S Collections.sort(sList2, new IdComparator()); System.out.println(&quot;\n\nList sorted according to id:&quot;); for (int i = 0; i &lt; sList2.size(); i++) System.out.println(sList2.get(i).toString()); S } }...
View Full Document

This note was uploaded on 03/25/2010 for the course CIS CIS3023 taught by Professor Seema during the Spring '10 term at Florida College.

Ask a homework question - tutors are online