package com.itheima;
import java.util.*;
public class ArrayListTest {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
ArrayList al=new ArrayList();
al.add("java01");
al.add("java02");
al.add("java03");
al.add("java03");
sop(al);
singleElemtent(al);
}
public static void singleElemtent (ArrayList Al)
{
ArrayList newAL=new ArrayList();
Iterator it=Al.iterator();
while(it.hasNext())
{
Object obj=it.next();
if(!newAL.contains(Al))
newAL.add(obj);
}
sop(newAL);
}
public static void sop(Object obj)
{
System.out.println(obj);
}
}//重复元素还是没有去掉错在哪里了? |
|