集册 Java实例教程 通过增强的for循环从LinkedList检索项目

通过增强的for循环从LinkedList检索项目

欢马劈雪     最近更新时间:2020-01-02 10:19:05

481
提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
通过增强的for循环从LinkedList检索项目
/* 
*来 自
 n o w j a   v  a . c o m - 时  代  Java
*/

import java.util.LinkedList;


public class Main {

  public static void main(String[] args) {

    LinkedList<String> officers = new LinkedList<String>();

    officers.add("Blake");

    officers.add("Bates");

    officers.add("Jack");

    officers.add("Tom");

    officers.add("Lady");

    officers.add(2, "new");

    for (String s : officers)

          System.out.println(s);
          /**
          来 自 时 代 J a v a - nowjava.com
          **/



  }


}