zoukankan      html  css  js  c++  java
  • 27.集合1------Collection

    1.学习目录

     2.集合类体系结构

     

     

     3.Collection概述

     4.Collection方法

     5.Collection的遍历(Iterator)

        public static void main(String[] args) {
            Collection<String> collection = new ArrayList<String>();
            collection.add("hello");
            collection.add("world");
            Iterator<String> iterator = collection.iterator();
    /**
     *     public Iterator<E> iterator() {
     *         return new Itr();
     *     }
     *
     *     private class Itr implements Iterator<E> {
     * ...
     *          }
     */
            /**
             System.out.println(iterator.next());//hello
             System.out.println(iterator.next());//world
             System.out.println(iterator.next());//Exception in thread "main" java.util.NoSuchElementException
             */
    /*        if (iterator.hasNext()){
                System.out.println(iterator.next());//hello
            }
            if (iterator.hasNext()){
                System.out.println(iterator.next());//hello
            }
            if (iterator.hasNext()){
                System.out.println(iterator.next());//无输出
            }*/
            //用while循环改进
    
            while (iterator.hasNext()) {
                System.out.println(iterator.next());
            }
    
        }
  • 相关阅读:
    router使用以及vue的动画效果
    配置wbepack
    Axios插件和loading的实现
    自定义组件的 v-model
    组件模块化使用
    组件基础
    vue的使用1
    solt插槽的使用。
    Vue的使用
    Vue的router使用
  • 原文地址:https://www.cnblogs.com/luzhanshi/p/13061256.html
Copyright © 2011-2022 走看看