1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package com.ww.yzpA;
 
public class Students {
    int No;
    int Height;
}
 
 
package com.ww.yzpA;
 
public class Height {
    public Students getMaxHeigth(Students[] str) {
        Students A = new Students();
        for (int i = 0; i < str.length; i++) {
            if (str[i].Height > A.Height) {
                A.Height = str[i].Height;
                A.No = str[i].No;
            }
        }
 
        return A;
 
    }
}
 
 
package com.ww.yzpA;
 
import java.util.Scanner;
 
public class Text {
 
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        Scanner in = new Scanner (System.in);
        Students [] stu = new Students[10];
        Height news=new Height();
        Students Stu=new Students();
        for (int i = 0; i < stu.length; i++) {
            System.out.println("请输入第"+(i+1)+"位学员的身高:");
            stu[i]= new Students();
            stu[i].Height=in.nextInt();
            stu[i].No=i+1;
        }
        Stu=news.getMaxHeigth(stu);    
    System.out.print("该班第"+Stu.No+"名学生身高最高,为"+Stu.Height);
    }
}