import java.util.Random;
public class SwitchDemo{
public static void main(String[] args){
int[] nums = new int[5];
//Random类可以加入一个seed数,控制产生的随机数不再变化,
// Random random = new Random(20);
Random random = new Random();
for(int i=0; i<nums.length;i++){
//java.lang.Math.random() [0.0~1)的double类型
// nums[i] = (int)(Math.random()*100);
//使用Random类,构建对象,用nextInt(100),生成100以内的整数
nums[i] = random.nextInt(100);
}
int min = 100;
for(int j=0;j<nums.length;j++){
if(nums[j]<=min){
min = nums[j];
}
}
System.out.println(min);
}
}
本文地址:https://blog.csdn.net/qq_36725221/article/details/107389280
如对本文有疑问, 点击进行留言回复!!
SpringBoot自定义异常错误数据后获取不到${exception}
Java switch() case中的switch可用的数据类型
网友评论