我使用stringbuilder完成它将o / p作为{abc=value-bb, abc=value-cc, abc=value-aa, abc=value-abc}
但想知道是否可以使用弱引用
答案 0 :(得分:0)
import java.util.HashMap;
class Hash {
public static void main(String[] args) {
HashMap<StringBuffer, String> mp = new HashMap<StringBuffer, String>();
mp.put(new StringBuffer("abc"),"value-abc");
mp.put(new StringBuffer("abc"),"value-abc");
mp.put(new StringBuffer("abc"),"value-abc");
StringBuffer ojas= null;
System.out.println(mp);
}
}
输出
{abc=value-abc, abc=value-abc, abc=value-abc}