List of usage examples for java.util LinkedList add
public boolean add(E e)
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);/* w ww .ja v a2 s. c om*/ }
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);/* w w w .j a v a2 s . c o m*/ System.out.println(list.getFirst()); System.out.println(list.getLast()); }
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);// w w w. 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("First element of LinkedList is : " + lList.getFirst()); System.out.println("Last element of LinkedList is : " + lList.getLast()); }
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"); for (String s : officers) System.out.println(s);/*from ww w. j a v a2 s . c om*/ }
From source file:Main.java
public static void main(String args[]) { LinkedList<String> ll = new LinkedList<String>(); ll.add("B"); ll.add("ja v a2s.com"); ll.addLast("E"); ll.add("F");/* ww w. j av a2 s .c o m*/ LinkedList<String> newList = new LinkedList<String>(ll); System.out.println(newList); }
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);/* w w w . j a v a 2 s .c o m*/ lList.set(3, "Replaced"); System.out.println(lList); }
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"); for (String str : lList) { System.out.println(str);/*from w ww. ja v a 2 s .c om*/ } }
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"); Iterator itr = lList.iterator(); while (itr.hasNext()) { System.out.println(itr.next()); }/*from www . jav a2s.c o m*/ }
From source file:Main.java
public static void main(String args[]) { LinkedList<String> ll = new LinkedList<String>(); ll.add("A"); ll.add("ja v a2s.com"); ll.addLast("B"); ll.add("C");/*from w ww .jav a 2 s .c o m*/ Iterator<String> itr = ll.iterator(); while (itr.hasNext()) { String element = itr.next(); System.out.print(element + " "); } }