List of usage examples for java.util LinkedList LinkedList
public LinkedList()
From source file:Main.java
public static void main(String[] args) { LinkedList<String> lList = new LinkedList<String>(); lList.add("1"); lList.add("2"); lList.add("3"); lList.add("4"); lList.add("5"); Object[] objArray = lList.toArray(); for (Object obj : objArray) { System.out.println(obj);/*from www.j a v a 2s .co m*/ } }
From source file:Main.java
public static void main(String[] args) { LinkedList<String> lList = new LinkedList<String>(); lList.add("1"); lList.add("2"); lList.add("3"); lList.add("4"); lList.add("5"); lList.add("2"); System.out.println(lList.indexOf("2")); System.out.println(lList.lastIndexOf("2")); }
From source file:Main.java
public static void main(String[] argv) throws Exception { LinkedList queue = new LinkedList(); Object object = ""; // Add to end of queue queue.add(object);// w ww . j av a 2 s. c o m // Get head of queue Object o = queue.removeFirst(); }
From source file:MainClass.java
public static void main(String[] a) { LinkedList<String> officers = new LinkedList<String>(); officers.add("B"); officers.add("B"); officers.add("H"); officers.add("P"); officers.add("M"); officers.add(2, "T"); for (String s : officers) System.out.println(s);//from w ww . jav a 2 s .com }
From source file:Main.java
public static void main(String[] args) { LinkedList<String> lList = new LinkedList<String>(); lList.add("1"); lList.add("2"); lList.add("3"); lList.add("4"); lList.add("5"); if (lList.contains("4")) { System.out.println("LinkedList contains 4"); } else {// w w w . j a va 2s . co m System.out.println("LinkedList does not contain 4"); } }
From source file:Main.java
public static void main(String[] args) { LinkedList<String> lList = new LinkedList<String>(); lList.add("1"); lList.add("2"); lList.add("3"); lList.add("4"); lList.add("5"); System.out.println(lList);/*from w ww . j a v a 2s. c om*/ System.out.println(lList.remove("2")); System.out.println(lList); Object obj = lList.remove(2); System.out.println(obj + " has been removed from LinkedList"); System.out.println(lList); }
From source file:MainClass.java
public static void main(String[] a) { LinkedList list = new LinkedList(); list.add("A"); list.add("B"); list.add("C"); list.add("D"); list.addFirst("X"); list.addLast("Z"); System.out.println(list);/*from w ww. ja v a 2 s. c o m*/ System.out.println(list.getFirst()); System.out.println(list.getLast()); list.removeFirst(); list.removeLast(); System.out.println(list); }
From source file:Main.java
public static void main(String[] args) { LinkedList<String> lList = new LinkedList<String>(); lList.add("1"); lList.add("2"); lList.add("3"); lList.add("4"); lList.add("5"); System.out.println(lList);/*www . j a v a 2s .com*/ lList.addFirst("0"); System.out.println(lList); lList.addLast("6"); System.out.println(lList); }
From source file:MainClass.java
public static void main(String[] a) { LinkedList<String> officers = new LinkedList<String>(); officers.add("B"); officers.add("B"); officers.add("T"); officers.add("H"); officers.add("P"); officers.add("McIntyre"); System.out.println(officers); officers.set(2, "Murdock"); System.out.println("\nTuttle is replaced:"); System.out.println(officers); }
From source file:Main.java
public static void main(String[] args) { Queue<String> queue = new LinkedList<String>(); queue.offer("First"); queue.offer("Second"); queue.offer("Third"); queue.offer("Fourth"); System.out.println(queue);/*from w ww . j a v a 2 s . co m*/ }