import java.util.Random;
/**
* 获取最大值最小值
* @author shaobn
*
*/
public class Test2 {
public static void main(String[] args) {
Random random = new Random();
int[] a = new int[10];
for (int i = 0; i < 10; i++) {
a[i] = random.nextInt(100)+1;
System.out.println(a[i]);
}
getMax(a);
getMin(a);
}
//最大值
public static void getMax(int a[]){
int temp = a[0];
for (int i = 0; i < a.length-1; i++) {
if(temp>a[i+1]){
continue;
}
temp = a[i+1];
}
System.out.println("最大值是:"+temp);
}
//最小值
public static void getMin(int a[]){
int temp = a[0];
for (int i = 0; i < a.length-1; i++) {
if(temp<a[i+1])
continue;
temp = a[i+1];
}
System.out.println("最小值是:"+temp);
}
}