D:\Sam\InterviewsMaterial\SiteWorx\SiteWorxTest\src\java\linkedlist_example_package\SimpleLinkedListExample.java |
1
2
3
4
5 package linkedlist_example_package;
6
7 import java.util.*;
8 import java.util.Iterator;
9 import java.util.LinkedList;
10
11
12 @author
13
14 public class SimpleLinkedListExample extends LinkedList
15 {
16
17 public SimpleLinkedListExample()
18 {
19 super();
20 }
21
22
23
24 public static void main (String[] args)
25 {
26 System.out.println("=============SimpleLinkedListExample Start =============");
27 SimpleLinkedListExample localSimpleLinkedListExample = new SimpleLinkedListExample();
28 localSimpleLinkedListExample.add("First value\n");
29 localSimpleLinkedListExample.addFirst("First First\n");
30 localSimpleLinkedListExample.addLast("Last\n");
31 localSimpleLinkedListExample.add("sam\n");
32 localSimpleLinkedListExample.add("joe\n");
33 localSimpleLinkedListExample.add("Mike\n");
34 System.out.println("Start Output ====>\n");
35 System.out.println(localSimpleLinkedListExample);
36 System.out.println("\nafter removing ====>\n");
37 localSimpleLinkedListExample.removeFirst();
38 localSimpleLinkedListExample.removeLast();
39 Iterator<String> localIterator = localSimpleLinkedListExample.iterator();
40 while(localIterator.hasNext())
41 {
42 System.out.println(localIterator.next());
43 }
44
45 System.out.println("end Output ====>\n");
46 }
47 }
48