student.txt文件由学生姓名,class_number(= ban),数字组成。 例如
jack 4 3
mike 1 4
key 3 5
peak 1 3
....
我想知道如何使class_number成为双向链表(如1-2-3-4-5)(ban等于class_number)。每个class_number都连接到学生双向链表(按编号排序) 最后它打印出数字名称(< 1class> 4迈克)
感谢您阅读
package nov25;
import java.io.File;
import java.io.IOException;
import java.util.LinkedList;
import java.util.Scanner;
class Ban {
private int ban;
private LinkedList<Student> list;
}
class Student {
private int no;
private String name;
}
public class P1 {
public static void main(String[] args) {
File file = new File("student.txt");
Scanner scin;
if (file.exists()) {
try {
scin = new Scanner(file);
while (scin.hasNext()) {
String name = scin.next();
int ban = scin.nextInt();
int no = scin.nextInt();
}
scin.close();
} catch (IOException e) {}
}
else {
System.out.println("score.txt not exist!!");
}
}
}