- package com.socket.all;
- import java.util.ArrayList;
- import java.util.Iterator;
- import java.util.Scanner;
- public class myList extends ArrayList<Object> {
- /**
- * @param args
- */
- public static void main(String[] args) {
- // TODO Auto-generated method stub
- ArrayList list = new ArrayList();
- Scanner scanner = new Scanner(System.in);
- System.out.println("请选择输入元素个数:");
- int sumObject = scanner.nextInt();
- for (int i = 0; i < sumObject; i++) {
- list.add(scanner.nextInt());
- }
- Iterator it = list.iterator();
- while (it.hasNext()) {
- list.removeRange(2,3);//JDK api分明是有这个函数的,可是这里怎么报错了?编译器的问题吗?
- System.out.println(it.next());
- }
- }
- }
复制代码 |
|