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);
}
}
网友评论