ClearCollection

2019-09-26  本文已影响0人  勇者与王者

package collectionDemo;

import java.util.ArrayList;

/**
* 
* @author q06285:
* @version 创建时间:2019年9月26日 下午2:52:32
* 
*/
public class ClearCollection {

    public static void main(String[] args) {
        // TODO Auto-generated method stub

        ArrayList<Hero> heros = new ArrayList<>();
        
        for (int i = 0 ; i < 5 ;i++) {
            heros.add(new Hero("Hero "+i));
        }
        
        System.out.println("ArrayList heros: \t"+heros);
        System.out.println("使用clear方法清空");
        heros.clear();
        System.out.println("ArrayList heros: \t"+heros);
        
        
        
    }

}

上一篇 下一篇

猜你喜欢

热点阅读