我有一个从用户读入的对象数组到数组列表中,当我尝试根据字符串参数对这些数据进行冒泡排序时,程序遇到运行时错误并且代码不执行。
Resort temp;
while (finished = true) {
finished = false;
for (int index = 0; index < numResorts - 1; index++) {
String nam1 = resorts.get(index).getName();
String nam2 = resorts.get(index + 1).getName();
if (nam1.compareTo(nam2) > 0) {
temp = resorts.get(index);
resorts.set(index, resorts.get(index + 1));
resorts.set(index + 1, temp);
//resorts.get(index) = resorts.get(index + 1);
//resorts.get(index + 1) = temp;
finished = true;
}
}
}