package com.sTudent;
import java.util.Arrays;
public class stuDent {
public static void main(String[] args) {
stuDent hello=new stuDent();
hello.Dges();
}
public int Dges(){
int[] ages={18,23,21,19,25,29,17};
Arrays.sort(ages);
int max=ages[0];
int min=ages[0];
for(int i=0;i<ages.length;i++){
if(ages[i]>max){max=ages[i];}
else if(ages[i]<min){min=ages[i];}
}
System.out.println("年龄按从小到大排序后为:"+Arrays.toString(ages));
System.out.println("最大的年龄为:"+max);
System.out.println("最小的年龄为:"+min);
return min;
}
}
相关分类