ore*_*ani 0 java sorting nullpointerexception compareto
我正在编写一个代码来从文件中读取一些记录并以特殊方式对它们进行排序.我尝试了这样的代码:
public class Main {
static class judgement implements Comparable<judgement> {
public int q;
public int d;
public int r;
public int compareTo(judgement j) {
int k = ((judgement) j).q;
return 0;
}
}
public static void method() throws Exception {
judgement[] judgements;
judgements = new judgement[18425];
try {
// fill the "judgements" array
} finally {
Arrays.sort(judgements);
}
}
public static void main(String[] args) throws Exception {
method();
}
Run Code Online (Sandbox Code Playgroud)
}
但是我在函数compareTo中得到错误NullPointerException.任何人都可以帮我解决这个问题吗?