import java.util.ArrayList;
import java.util.Iterator;
public class ArrayList1 {
public static void main(String[] args) {
ArrayList<Object> arrayList = new ArrayList<>();
arrayList.add("字符串");
arrayList.add(15343);
arrayList.add('a');
System.out.println("集合的长度:"+arrayList.size());
System.out.println("--------------");
System.out.println("遍历集合:");
for (Object o : arrayList) {
System.out.println(o);
}
System.out.println("--------------");
Iterator<Object> iterator = arrayList.iterator();
while (iterator.hasNext()) {
Object next = iterator.next();
System.out.println(next);
}
}
}
软件二班——夏佳豪26
最新推荐文章于 2024-11-08 14:58:24 发布