Adding Items to a LinkedList with add method - Java Collection Framework

Java examples for Collection Framework:LinkedList

Description

Adding Items to a LinkedList with add method

Demo Code

import java.util.LinkedList;

public class Main {
  public static void main(String[] args) {
    LinkedList<String> officers = new LinkedList<String>();
    officers.add("Blake");
    officers.add("Mary");
    officers.add("Edith");
    officers.add("P");
    officers.add("Lady");

    for (String s : officers)
      System.out.println(s);/*from  www.  j a  v  a 2s.co  m*/

  }

}

Related Tutorials