package com.luan.test;
import java.util.Random;
public class First {
public static void main(String[] args) {
int [] randoms = new int[20];
Random random = new Random();
int count=0;
while(count !=20){
int rand = random.nextInt(900) +100;
if(rand%2 ==0){
randoms[count++] = rand;
}
}
int sum = 0;
for(int i : randoms){
sum +=i;
}
System.out.println("随机数之和为"+sum);
}
} |