美文网首页
ClearCollection

ClearCollection

作者: 勇者与王者 | 来源:发表于2019-09-26 14:54 被阅读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);
        
        
        
    }

}

相关文章

网友评论

      本文标题:ClearCollection

      本文链接:https://www.haomeiwen.com/subject/wixnuctx.html