ちょうきょう666

导航

javaList接口

public class Demo5 {
 public static void main(String[] args) {
  // TODO Auto-generated method stub
  List list=new ArrayList();
  list.add("ZG");
  list.add("RR");
  list.add("pp");
  System.out.println(list.size());
//  System.out.println(list.toString());
  ListIterator lit=list.listIterator();//声明迭代器
  while(lit.hasNext()) {
   System.out.println(lit.nextIndex()+":"+lit.next());
  }
  while(lit.hasPrevious()) {//反向遍历
   System.out.println(lit.previousIndex()+":"+lit.previous());
  }
  boolean iff=list.contains("Z");
  System.out.println(iff);
 }
}

posted on 2020-05-27 09:57  ちょうきょう666  阅读(120)  评论(0编辑  收藏  举报