import java.util.LinkedList;
public class exLinkedList{
static LinkedList<String> myLinkedList;
public static void main(String[] args){
System.out.println("LinkedList Exerecise");
myLinkedList = new LinkedList<String>();
myLinkedList.add("ABCDEF");
myLinkedList.add("G");
myLinkedList.add("HIJ");
myLinkedList.add("KLM");
myLinkedList.add("NOPQRST");
myLinkedList.add("UVW");
myLinkedList.add("XYZ");
showAll();
System.out.println();
myLinkedList.removeFirst();
myLinkedList.removeLast();
myLinkedList.remove("KLM");
myLinkedList.remove("JAVA"); //Can't found!
showAll();
}
static void showAll(){
for(int i = 0; i < myLinkedList.size(); i++){
System.out.println(myLinkedList.get(i));
}
}
}
Monday, October 3, 2011
Exercise on LinkedList
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment