List of usage examples for java.util LinkedList LinkedList
public LinkedList()
From source file:MainClass.java
public static void main(String[] a) { List list = new LinkedList(); list.add("A"); list.add("B"); list.add("C"); list.add("D"); ListIterator iter = list.listIterator(list.size()); while (iter.hasPrevious()) { System.out.println(iter.previous()); iter.add("a"); break;/*from w w w. ja v a2s . c o m*/ } System.out.println(list); }
From source file:Main.java
public static void main(String[] a) { List<String> list = new LinkedList<String>(); list.add("A"); list.add("B"); list.add("C"); list.add("D"); ListIterator<String> iter = list.listIterator(list.size()); while (iter.hasPrevious()) { System.out.println(iter.previous()); iter.add("a"); break;//from ww w .j av a 2 s . c om } System.out.println(list); }
From source file:Main.java
public static void main(String[] args) { Deque<String> deque = new LinkedList<>(); deque.addLast("Oracle"); deque.offerLast("Java"); deque.offerLast("CSS"); deque.offerLast("XML"); System.out.println("Deque: " + deque); // remove elements from the Deque until it is empty while (deque.peekFirst() != null) { System.out.println("Head Element: " + deque.peekFirst()); deque.removeFirst();/*from w w w . j av a2 s . c o m*/ System.out.println("Removed one element from Deque"); System.out.println("Deque: " + deque); } // the Deque is empty. Try to call its peekFirst(), // getFirst(), pollFirst() and removeFirst() methods System.out.println("deque.isEmpty(): " + deque.isEmpty()); System.out.println("deque.peekFirst(): " + deque.peekFirst()); System.out.println("deque.pollFirst(): " + deque.pollFirst()); String str = deque.getFirst(); System.out.println("deque.getFirst(): " + str); str = deque.removeFirst(); System.out.println("deque.removeFirst(): " + str); }
From source file:Main.java
public static void main(String[] args) { LinkedList<String> myQueue = new LinkedList<String>(); myQueue.add("A"); myQueue.add("B"); myQueue.add("C"); myQueue.add("D"); List<String> myList = new ArrayList<String>(myQueue); for (Object theFruit : myList) System.out.println(theFruit); }
From source file:Main.java
public static void main(String[] args) { List<Integer> stack = new LinkedList<Integer>(); Producer producer = new Producer(stack); Consumer consumer = new Consumer(stack); producer.start();//from w w w . j av a 2 s . c o m consumer.start(); }
From source file:MainClass.java
public static void main(String[] args) { Queue queue = new LinkedList(); queue.add("Hello"); queue.add("World"); List list = new ArrayList(queue); System.out.println(list);//from w w w . j av a 2s .c o m }
From source file:Main.java
public static void main(String args[]) { List<Character> ll = new LinkedList<Character>(); for (char n = 'A'; n <= 'F'; n++) ll.add(n);//w ww.j av a 2 s . com System.out.println(ll); Collections.reverse(ll); System.out.println(ll); Collections.rotate(ll, 2); System.out.println(ll); Collections.shuffle(ll); System.out.println(ll); }
From source file:Main.java
public static void main(String[] args) { Queue<String> queue = new LinkedList<String>(); queue.add("Hello"); queue.add("World"); List<String> list = new ArrayList<String>(queue); System.out.println(list);// w ww . j a v a 2 s .c om }
From source file:Main.java
public static void main(String args[]) { List<Character> ll = new LinkedList<Character>(); for (char n = 'A'; n <= 'Z'; n++) ll.add(n);//w ww.ja va 2 s . co m Collections.shuffle(ll); for (Character x : ll) System.out.print(x + " "); Collections.sort(ll); for (Character x : ll) System.out.print(x + " "); System.out.println("Searching for F."); int i = Collections.binarySearch(ll, 'F'); if (i >= 0) { System.out.println("Found at index " + i); System.out.println("Object is " + ll.get(i)); } }
From source file:Main.java
public static void main(String[] args) { Queue<String> myQueue = new LinkedList<String>(); myQueue.add("A"); myQueue.add("B"); myQueue.add("C"); myQueue.add("D"); List<String> myList = new ArrayList<String>(myQueue); for (Object theFruit : myList) System.out.println(theFruit); }