【发布时间】:2015-12-17 09:48:13
【问题描述】:
我试图通过两个标准对ArrayList 进行排序:在行和列中都升序。我收到以下错误:
Multiple markers at this line
- Syntax error on tokens, delete these tokens
- The method RowColElem() is undefined for the type
DenseBoard<T>
- The method RowColElem() is undefined for the type
DenseBoard<T>
- Syntax error on tokens, delete these tokens
这是我的代码的简化版本:
public class DenseBoard<T>{
private ArrayList<RowColElem<T>> tempDiagList;
public void foo() {
Collections.sort(tempDiagList, Comparator.comparingInt(RowColElem::getRow())
.thenComparingInt(RowColElem::getCol()));
}
}
【问题讨论】:
-
去掉
RowColElem::getRow()和RowColElem::getCol()的括号。 -
还是一样。我做了
RowColElem::getRow和RowColElem::getCol但仍然出现错误。Multiple markers at this line - RowColElem cannot be resolved to a variable - Syntax error on tokens, delete these tokens - Syntax error on tokens, delete these tokens - RowColElem cannot be resolved to a variable -
您确定使用 Java 8 进行编译吗?你在使用 IDE 吗?
-
然后尝试将您的示例减少到最小的示例。您的帖子中的代码过多。
-
我编辑了您的帖子以删除所有不必要的代码,以便更容易看到真正的问题。
标签: java sorting arraylist java-8