我正在自学 Java,当我在 Eclipse 的剪贴簿中运行代码时遇到此错误:
Syntax error, insert "AssignmentOperator Expression" to complete Expression
这是我的剪贴簿:
Sorter sorter = new Sorter();
int[] nums = {5, 6, 7, 8, 1, 2, 3, 4};
sorter.selectionSort(nums);
nums;
这是排序器类。
public class Sorter {
public void selectionSort(int[] numbers) {
for (int i = 0; i < numbers.length - 1; i++) {
int leastPosition = i;
for (int j = i + 1; j < numbers.length; j++) {
if (numbers[j] < numbers[leastPosition])
leastPosition = j;
}
int temp = numbers[leastPosition];
numbers[leastPosition] = numbers[i];
numbers[i] = temp;
}
}
}
什么是错?我在任何地方都找不到丢失的赋值运算符。