1	package antlr.collections;
2	
3	import antlr.collections.List;
4	import antlr.collections.impl.LList;
5	import java.util.Enumeration;
6	import java.util.NoSuchElementException;
7	
8	public class LListTest {
9	
10	
11		public static void main(String[] args) {
12			// create a linked list, but treat it like a List
13			LList l = new LList();
14			List list = l;
15			list.add("Hi there");
16			list.add("Frank");
17		   list.add("Zappa");
18			list.add(new Integer(4));
19			
20			// Test length()
21			if ( list.length()!=4 )
22				System.out.println("incorrect length");
23			else
24				System.out.println("correct: length is 4");
25			
26			// Test the enumeration (view it as a LList)
27			Enumeration e = l.elements();
28			for (; e.hasMoreElements();) {
29				System.out.println(e.nextElement());
30			}
31	
32			// Test includes()
33			if ( list.includes("Frank") )
34				System.out.println("correct: contains Frank");
35			else
36				System.out.println("incorrect: does not contain Frank");
37		
38			// Test elementAt()
39			Object o;
40			o = list.elementAt(2);
41			System.out.println("elementAt(2) replies: "+o);
42			try {
43				o = list.elementAt(200);
44				System.out.println("elementAt(200) replies: "+o);
45			} catch (NoSuchElementException ex) {
46				System.out.println("correct: no such element: 200");
47			}
48		}
49	}
50