Java排序问题

来源:百度知道 编辑:UC知道 时间:2024/05/04 12:43:40
我要做个学生成绩管理系统,变量为num(学号)fenshu(分数)name(姓名)sex(性别)banji(班级),这些都用LinkedList定义,现在想做个排序功能,让其能按学号或分数排序。用J2SE写哈,谢谢各位大牛了。

/*做个学生成绩管理系统,变量为num(学号)fenshu(分数)name(姓名)
sex(性别)banji(班级),这些都用LinkedList定义,现在想做个排序功能,
让其能按学号或分数排序*/
import java.util.LinkedList;
import java.util.Scanner;
import java.io.*;

public class aaa
{
public static void main(String[] args)throws IOException
{
student s = new student();
Scanner sc = new Scanner(System.in);
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

System.out.print("input the number of student:");
n = sc.nextInt();

for (int i = 0; i < n; i++)//输入
{
System.out.print("the " + (i+1) + "student's num:");
s.num = br.readLine();
System.out.print("the " + (i+1) + "student's fenshu:");
s.fenshu = Float.parseFloat(br.readLine());
System.out.print("the " + (i+1) + "student's name:");
s.name = br.readLine();<