此代码正在产生一个无限循环:
for (String element : friendSet) {
resultNum ++;
System.out.println(" Result # " + resultNum + " = " + element);
System.out.print(" friendSet.size() = " + friendSet.size());
}
friendSet.size() = 2923 但结果不断攀升至数万,直到我强制程序停止。例如:
friendSet.size() = 2923 Result # 7652 = Charlie
friendSet.size() = 2923 Result # 7653 = Jamie
friendSet.size() = 2923 Result # 7654 = Smith
到底是怎么回事?