All pastes #354677 Raw Edit

Anonymous

public java v1 · immutable
·published 2007-02-14 02:29 UTC
rendered paste body
public class ListTester {    /**     * @param args     */    public static void main(String[] args) {        IntegerList myList = new IntegerList();                System.out.println("Attempt some insertions ... ");        myList.insert(15, 1);        myList.insert(25, 2);        myList.insert(10, 1);        myList.insert(05, 3);        myList.insert(40, 5);        myList.insert(65, 3);        myList.insert(50, 4);        myList.insert(-100, 6);        myList.insert(55, 8);                System.out.println("After 10 insertions, list contains:");        myList.printList();                System.out.println("Now attempting what looks like an illegal insertion...");                // Food for thought:  why does this work?        myList.insert("xyz", 7);        myList.printList();        System.out.println("Attempt some deletions ... ");        myList.remove(6);        myList.remove(1);        myList.remove(8);                System.out.println("After 3 removals, list now contains:");        myList.printList();                int targetPos = myList.find(40);        if (targetPos == 0) {            System.out.println("Value 40 not present on list.");        } else {        	System.out.println("Value 40 present on list in position " + targetPos);        }                targetPos = myList.find(55);        if (targetPos == 0) {            System.out.println("Value 55 not present on list.");        } else {            System.out.println("Value 55 present on list in position " + targetPos);        }    }}