package Mytest;
public class Ages {
public static void main(String[] args) {
Ages hello=new Ages();
int maxscore = hello.getMaxAge();
System.out.println("最大年齡是:"+maxscore);
}
public int getMaxAge() {
int[] ages = {18, 23, 21, 19, 25, 29, 17};
int MaxAge = ages[0];
for (int tmp:ages) {
if(MaxAge<ages[tmp]) {
MaxAge=ages[tmp];
}
}
return MaxAge;
}
}