重新排序字符串

以下代码可以正常工作,但产生为 鲍勃·玛丽·杰夫 82 65 23

我可以更改些什么以对String重新排序以使其看起来像 鲍勃82 \ n 玛丽65 \ n 杰夫23

此外,我想为每个等级设置一个范围,例如,等级超过85的是“ HD”,等级85-75是“ D”,74 -65是“ C”,64 -55是“ P”,54-0是“ F”。 因此,与其给鲍勃,玛丽和杰夫一个实际的成绩,不如给他们一个间隔。例如:Bob D,Mary C,GeoffF。

public class Student {
    String[] names;
    int[] grades;
    
    public Student(int numStudents) {
        this.names = new String[numStudents];
        this.grades = new int[numStudents];
    }
    
    public void addStudent(String name, int grade) {
        int i = 0;
        while (i < this.names.length && names[i] != null) {
            i++;
        }
        if (i < names.length) {
            names[i] = name;
            grades[i] = grade;
        }
    }
    public String toString() {
        String result = "";
        for (int i=0; i < this.names.length; i ++) {
            result += this.names[i] + " ";

        }
        result += "\n";
        for (int i = 0; i< this.grades.length; i++) {
            result += this.grades[i] + " ";


        }
        return result;
    }
    public static void main(String[] args) {
        
        Student classRoom  = new Student(3);
        classRoom.addStudent("Bob", 82);
        classRoom.addStudent("Mary", 65);
        classRoom.addStudent("Geoff", 23);

        System.out.println(classRoom);
    }