返回类型是List,我声明list用于返回,我如何在new之后实际声明它?
public List<Record> findClosestRecords(int n) throws IndexException {
if (!sorted || n > records.size()) {
}
List<Record> list = new ;
for (int i = 0; i < n; i++) {
Record r = this.records.get(i);
list.add(i, r);
}
return list;
}
Run Code Online (Sandbox Code Playgroud) java ×1