horse1ProgressionStr = Integer.toString(horse1Progression);
horse2ProgressionStr = Integer.toString(horse2Progression);
horse3ProgressionStr = Integer.toString(horse3Progression);
horse4ProgressionStr = Integer.toString(horse4Progression);
List<List<String>> list = Arrays.asList(Arrays.asList(horse1ProgressionStr, horse2ProgressionStr, horse3ProgressionStr, horse4ProgressionStr));
for (List<String> l : list) {
Collections.sort(l);
}
Collections.sort(list, new Comparator<List<String>>() {
public int compare(List<String> o1, List<String> o2) {
return o1.get(0).compareTo(o2.get(0));
}
});
System.out.println("" + list);
List<List<String>> fourthHorse = list.subList(0, 2);
List<List<String>> thirdHorse = list.subList(2, 4);
List<List<String>> secondHorse = list.subList(4, 6);
我一直試圖把4個整數按順序,他們把它們放到單獨的變量,但我嘗試它的每一個方式似乎給我一個越界例外。subListString索引超出界限
異常=
異常在線程 「主」 java.lang.IndexOutOfBoundsException:toIndex = 2
你在列表中有一個**列表'''列表' –