学习了一些Java相关的内容。
今日内容:
ArrayList的其他基本方法:
package test; import java.util.ArrayList; import java.util.Collection; import java.util.Iterator; import java.util.List; public class NewDemo { public static void main(String[] args) { //创建Collection对象 Collection coll = new ArrayList(); for(int i=0;i<10;i++) coll.add(i+1); System.out.println(coll); // 创建List对象 List list = new ArrayList(); for (int i=0;i<10;i++) list.add(i+1); System.out.println(list); list.clear(); System.out.println(list); System.out.println(list.contains(1)); // List的遍历(迭代器) for (int i=0;i<10;i++) list.add(i+1); Iterator it = list.iterator(); while (it.hasNext()){ System.out.print(it.next()+" "); } } }
问题:无
明天的打算:继续学习Java基础