底层是用HashMap来实现
HashMap map;
private static final int VALUE=10;
public test()
{
map=new HashMap();
}
public void add(Object obs) //将输入的值作为HashMap的键,从而达到不重复
{
map.put(obs, VALUE);
}
public int size()
{
return map.size();
}
public String toString()
{
StringBuilder ss=new StringBuilder();
for(Object s:map.keySet())
{
ss.append(s+",");
}
ss.setCharAt(ss.length()-1, ' ');
return ss.toString();
}