求大神帮助,帮忙改一改,谢谢

package test; public class Student { public String name; int age; public Student(String name,int sex) { this.name=name; this.age=sex; } //public interface Comparator<T> class Student implements Comparator<Student>{ private String name; private int age; public Student(String name,int sex) { this.name=name; this.age=sex;} public int compareTo(Student a){ return this.age().compareTo(a.age()); } } public String toString() { return name+":"+age+"岁"; } public String getName(){ return name;} public void setName(String name){ this.name=name;} public int getAge(){ return age;} public void setAge(int age){ this.age=sex;} } } import java.util.Arrays; public class Test { public static void sort(short[] a, int fromIndex, int toIndex){ } public static void main(String[] args) { Student[] a = new Student[] { new Student("zhangsan", 20), new Student("lisi", 22), new Student("wangwu", 18) }; Arrays.sort(a);//要求学生按年龄从小到大进行排序 System.out.println(Arrays.toString(a)); } }
慕粉2127281907
浏览 1202回答 2
2回答

ziom

代码格式化一下,这样一坨没法看
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java