import java.util.Vector;
public class TestVector
{
public static void main(String[] args)
{
}
Vector<Object> distinct(Vector<Object> oldVector)
{
Vector<Object> newVector = new Vector<Object>();
for(int i = 0;i < oldVector.size();i++)
{
Object obj = oldVector.get(i);
if(!newVector.contains(obj))
{
newVector.add(obj);
}
}
return newVector;
}
}
另一种简单的方法:
HashSet set = new HashSet(vector);