在我的程序中,创建了一个fClasses固定长度[7]的对象数组,每个对象都是一个FClass包含3 Strings,an int和a的类int[].这些值从.txt文件中读取,并根据其值添加到数组的特定索引中int..txt文件中的条目较少,然后数组中有索引,因此数组最终看起来像这样:
fClasses[0] { str1, str2, str3, int1, int [] {1,2,3,4,5}}
fClasses[1] { str1, str2, str3, int1, int [] {1,2,3,4,5}}
fClasses[2] { str1, str2, str3, int1, int [] {1,2,3,4,5}}
fClasses[3] null
fClasses[4] null
fClasses[5] { str1, str2, str3, int1, int [] {1,2,3,4,5}}
fClasses[6] { str1, str2, str3, int1, int [] {1,2,3,4,5}}
Run Code Online (Sandbox Code Playgroud)
在稍后的节目,我需要的基础上平均的数组排序ints的int[].我有一个工作方法来返回这个,但当我尝试使用数组排序时compareTo,Arrays.sort我得到一个很长的错误列表,从这些开始:
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at java.util.ComparableTimSort.countRunAndMakeAscending(Unknown Source)
at …Run Code Online (Sandbox Code Playgroud)