标签:不重复 test map size for obs int void shm
底层是用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();
}
标签:不重复 test map size for obs int void shm
原文地址:https://blog.51cto.com/14437184/2422055