public void removeDups() {
int i, k, j, lastFound = 0;
if (this.nElements < 1) {
System.out.println("Empty Array");
} else {
for (i = 0; i < this.nElements; i = lastFound) //outer loop
{
for (j = i + 1; j < this.nElements; j++) {
if (this.arr[i] == this.arr[j]) {
lastFound = i;
for (k = i; k < this.nElements; k++) {
this.arr[k] = this.arr[k + 1];
}
this.nElements--;
break;
}
}
}
for (i = 0; i < this.nElements; i++) {
System.out.println(this.arr[i]);
}
}
}
以前的方法從對象中刪除重複調用它(陣列)開始時,問題是,我想外環從某一位置每個增量開始,我賦值將該位置添加到變量lastFound中,並將該變量放在循環的增量部分,但程序會進入無限循環並永不停止,那麼問題是什麼?外for循環從某一位置