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"); System.out.println(lList);/* ww w .ja va 2 s. c o m*/ List lst = lList.subList(1, 4); System.out.println(lst); lst.remove(2); System.out.println(lst); System.out.println(lList); }
From source file:Main.java
public static void main(String[] args) { List<String> theList = new LinkedList<String>(); theList.add("A"); theList.add("B"); theList.add("C"); theList.add("D"); String[] my = theList.toArray(new String[theList.size()]); for (int i = 0; i < my.length; i++) { System.out.println(my[i]); }/* www . j ava2s. c o m*/ }
From source file:Main.java
public static void main(String[] args) { List<String> theList = new LinkedList<String>(); theList.add("A"); theList.add("B"); theList.add("C"); theList.add("D"); String[] my = theList.toArray(new String[0]); for (int i = 0; i < my.length; i++) { System.out.println(my[i]); }//from w w w . j a va 2s . co m }
From source file:Main.java
public static void main(String[] args) { LinkedList<String> linkedList = new LinkedList<String>(); linkedList.push("A"); linkedList.push("B"); linkedList.push("C"); linkedList.push("D"); ArrayList<String> arrayList = new ArrayList<String>(linkedList); for (String s : arrayList) { System.out.println("s = " + s); }/*from w w w . j av a 2 s . c om*/ }
From source file:Main.java
public static void main(String[] args) { LinkedList<String> list = new LinkedList<String>(); list.add("Hello"); list.add("from java2s.com"); list.add("java tutorial"); // print the list System.out.println("LinkedList:" + list); // create an array and copy the list to it Object[] array = list.toArray(); System.out.println(Arrays.toString(array)); }
From source file:Main.java
public static void main(String[] argv) throws Exception { LinkedList queue = new LinkedList(); Object object = ""; queue.add(object);// ww w.j a v a 2 s .co m Object o = queue.removeFirst(); queue = (LinkedList) Collections.synchronizedList(queue); }
From source file:Main.java
public static void main(String[] args) { Queue<String> queue = new LinkedList<String>(); queue.add("A"); queue.add("B"); queue.offer("C"); queue.offer("D"); System.out.println("remove: " + queue.remove()); System.out.println("element: " + queue.element()); System.out.println("poll: " + queue.poll()); System.out.println("peek: " + queue.peek()); }
From source file:Main.java
public static void main(String[] args) { // create a LinkedList LinkedList<String> list = new LinkedList<String>(); // add some elements list.add("Hello"); list.add("from java2s.com"); list.add("10"); // print the list System.out.println("LinkedList:" + list); // peek at the first element System.out.println("First element of the list:" + list.peekFirst()); }
From source file:Main.java
public static void main(String[] args) { LinkedList<String> list = new LinkedList<String>(); // add some elements list.add("Hello"); list.add("from java2s.com"); list.add("java tutorial"); System.out.println(list);/*from w w w. j av a 2 s . c om*/ // create an array and copy the list to it Object[] array = list.toArray(new Object[4]); System.out.println(Arrays.toString(array)); }
From source file:Main.java
public static void main(String[] args) { // create a LinkedList LinkedList<String> list = new LinkedList<String>(); // add some elements list.add("Hello"); list.add("from java2s.com"); list.add("10"); // print the list System.out.println("LinkedList:" + list); // print element at index 3 System.out.println("Element at index 3 :" + list.get(3)); }