package test;
public class Student {
private String name;
private int age;
public Student(String name,int age){
this.name=name;
this.age=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 = age;
}
}
package test;
import java.util.Arrays;
public class Main {
public static void main(String[] args) {
Student [] studentInfo=new Student[5];
studentInfo[0]=new Student("张", 10);
studentInfo[1]=new Student("张", 9);
studentInfo[2]=new Student("李", 3);
studentInfo[3]=new Student("王1", 7);
studentInfo[4]=new Student("王2", 88);
Student [] newStudentInfo=Main.selectSort(studentInfo);
for(int i=0;i
}
}
public static Student [] selectSort(Student [] studentInfo){//选择排序算法
for (int i=0;i
for (int j=i+1;j
min=j;
}
}
if (min!=i){
Student temp=studentInfo[i];
studentInfo[i]=studentInfo[min];
studentInfo[min]=temp;
}
}
return studentInfo;
}
}