栈异常信息为:
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
at java.util.Arrays.copyOf(Arrays.java:2882)
at java.lang.AbstractStringBuilder.expandCapacity(AbstractStringBuilder.java:100)
at java.lang.AbstractStringBuilder.append(AbstractStringBuilder.java:390)
at java.lang.StringBuilder.append(StringBuilder.java:119)
at com.xxx.mobile.xx.XXXXClass.main(XXXXClass.java:93)
仔细检查XXXXClass.java类的第93行,发现:
if (phoneUidMap.containsKey(phone)) { phoneUidMap.put(phone, phoneUidMap + "," + uid); //这是第93行 } else { phoneUidMap.put(phone, uid); }
直接把一个map和字符串进行连接了,其实是想如果map中已经包含就把原value追加上新value,由于疏忽把map.get(xxx)漏写成了map。改成
phoneUidMap.put(phone, phoneUidMap.get(phone) + "," + uid);
就运行成功了。