天天看点

java list 排序 int_java – 如何每5个元素对一个intList进行排序

我从txt文件中插入数千个数字到列表中,我想每5个数字对它们进行排序.这是可能的,如果是的话,如何做到这一点?

public static void readFromFile(){

List putInList = new ArrayList();

int jNum;

TextIO.readFile("jokerNums.txt");//read from a spesific file.

try{

do{

jNum = TextIO.getInt();

putInList.add(jNum);

} while(!TextIO.eof());// Test whether the next character in

//the current input source is an end-of-file

}

catch(IllegalArgumentException e){

}

TextIO.put(putInList);

}

我已经在do {} while循环中尝试了for循环,但是它的无限.

仅举几个插入的数字是9785.

先感谢您.