{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Main - list2.add(new Student(1"A" list2.add(new...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
import java.io.*; import java.util.*; i public class Main { p public static void main(String[] args) { ArrayList<String> sList = new ArrayList<String>(); A sList.add("Wenjie"); sList.add("Max"); sList.add("A"); sList.add("S"); sList.add("D"); s MyCollections.insertionSort(sList); MyCollections.printList(sList); M LinkedList<Integer> list1 = new LinkedList<Integer>(); list1.add(5); list1.add(2); list1.add(8); list1.add(50); list1.add(12); list1.add(0); list1.add(5); MyCollections.insertionSort(list1); M MyCollections.printList(list1); M ArrayList<Student> list2 = new ArrayList<Student>();
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: list2.add(new Student(1, "A")); list2.add(new Student(2, "D")); list2.add(new Student(3, "B")); list2.add(new Student(4, "C")); MyCollections.insertionSort(list2); M MyCollections.printList(list2); M } } class Student implements Comparable<Student>{ int id; String name; S public Student(int id, String name) { this.id = id; this.name = name; } public String toString() { return "(" + name + "," + id + ")"; } public int compareTo(Student s){ return name.compareTo(s.name); } } }...
View Full Document

{[ snackBarMessage ]}

Page1 / 2

Main - list2.add(new Student(1"A" list2.add(new...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon bookmark
Ask a homework question - tutors are online