package cn.itcast_01;
import java.util.ArrayList;
import java.util.Iterator;
public class 去除ArrayList集合重复的元素 {
public static void main(String[] args) {
ArrayList array = new ArrayList();
array.add("hello");
array.add("word");
array.add("java");
array.add("hello");
array.add("word");
array.add("java");
array.add("asff");
for(int x =0;x<array.size();x++) {
for(int y=x+1;y<array.size();y++) {
if(array.get(x).equals(array.get(y))) {
array.remove(y);
y--;
}
}
}
Iterator it = array.iterator();
while(it.hasNext()) {
String s= (String)it.next();
System.out.println(s);
}
}
}