import java.util;
class ArrayListDemo
{
public static void main(String[] args)
{
ArrayList c=new ArrayList();
c.add("java1");
c.add("java3");
c.add("java1");
c.add("java2");
System.out.println(SingleElements.setElement(c));
}
}
class SingleElements
{
public static ArrayList newA=new ArrayList();
public static ArrayList setElement(ArrayList c)
{
Iterator a=c.iterater();
while(a.hasNext())
{
Object obj=a.next();
while(!newA.contains(obj))
{
newA.add(object);
}
}
}
return newA;
} |
|