public class Student implements Comparable<Student>
{
int index;
double heigth;
public Student(int index, double heigth)
{
this.index = index;
this.heigth = heigth;
}
public int getIndex()
{
return index;
}
public void setIndex(int index)
{
this.index = index;
}
public double getHeigth()
{
return heigth;
}
public void setHeigth(double heigth)
{
this.heigth = heigth;
}
@Override
public int compareTo(Student o)
{
if (heigth > o.heigth)
{
return -1;
}
else if (heigth == o.heigth)
{
return 0;
}
else
{
return 1;
}
}
}
public class Height
{
public Student getMaxHeigth(Student[] students)
{
Arrays.sort(students);
return students[0];
}
public static void main(String[] args)
{
int i = 0;
Student[] students = new Student[10];
while (i < 10)
{
System.out.print("请输入第" + (i + 1) + "个学生的升高:");
Scanner scanner = new Scanner(System.in);
double heigth = scanner.nextDouble();
students[i] = new Student(i + 1, heigth);
i++;
}
Height height = new Height();
Student student = height.getMaxHeigth(students);
System.out.println("该班第" + student.getIndex() + "学生身高最高为:"
+ student.getHeigth());
}
}
追问public Student(int index, double heigth)
{
this.index = index;
this.heigth = heigth;
这段代码中的this是什么意思呢??
请大虾解释下!我是初学java