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

Java examples for Collection Framework:LinkedList

Description

Adding Items to a LinkedList with addLast method

Demo Code

import java.util.LinkedList;

public class Main {
  public static void main(String[] args) {
    LinkedList<String> officers = new LinkedList<String>();
    officers.addFirst("B");
    officers.addFirst("M");
    officers.addFirst("D");
    officers.addFirst("P");
    officers.addFirst("L");

    for (String s : officers)
      System.out.println(s);//from w ww.  j a  v a2s. com

  }

}

Related Tutorials