[AppleScript] 纯文本查看 复制代码 package day05;
import java.util.Random;
/**
* @Author: hjj
* @Date: 2019/3/18 19:12
* @Version 1.0
*/
public class Demo {
public static void main(String[] args) {
int[] arr = new int[5];
Random random = new Random();
for (int i = 0; i <arr.length ; i++) {
int num = random.nextInt(46) + 5;
arr[i] = num;
}
//遍历生成随机数后的数据
System.out.println("随机生成的数组中的元素是:");
bianLi(arr);
int[] newArr = getNewArr(arr);
System.out.println();
System.out.println("调用方法修改后的数组中的元素是:");
bianLi(newArr);
}
public static int[] getNewArr(int[] arr){
for (int i = 0; i <arr.length ; i++) {
if(arr[i]<10){
arr[i] = 0;
}
}
return arr;
}
public static void bianLi(int[] arr){
for(int i= 0;i<arr.length;i++){
System.out.print(arr[i]+" ");
}
}
} |