首页 > 技术文章 > 增强for循环

hph1728390 2019-03-21 13:47 原文

public class LinkedlistDome {

    public static void main(String[] args) {

    fun();

}

    public static void fun(){

          //创建多态集合
            Collection<String >co=new ArrayList<String>();

 

t          //添加字符串
              co.add("d");
              co.add("f");
              co.add("e");

        //使用增强for循环遍历
              for(String i:co){
                  System.out.println(i);
              }
    }

}

推荐阅读