- import java.util.ArrayList;
- import java.util.Iterator;
- public class Demo33{
-
- public static void main(String[] args){
-
- ArrayList al=new ArrayList();
- al.add(new Person("张三",16));
- al.add(new Person("李四",17));
- al.add(new Person("张三",16));
- al.add(new Person("王五",26));
- al.add(new Person("张三",16));
- al.add(new Person("王五",26));
-
- al=removeSameEmplement(al);
- System.out.println(al);
- }
-
- public static ArrayList removeSameEmplement(ArrayList al){
- ArrayList temp=new ArrayList();
-
- Iterator it = al.iterator();
-
- while(it.hasNext())
- Object obj=it.next();
- if(!temp.contains(obj)){
- temp.add(obj);
- }
- return temp;
- }
- }
复制代码 编译出错,总提示- Exception in thread "main" java.lang.Error: Unresolved compilation problem:
- at cn.itcast0627.Demo33.main(Demo33.java:8)
复制代码 请大侠帮我找出错误 |