我需要创建一个整数数组(双精度和浮点数也可以,但我认为没有区别),因为我需要对它们进行某些数学运算,例如 * 和 +。我正在尝试用随机种子(即 1337 5443,我需要使用这些)填充数组,但我无法将随机变量转换为 int,也无法添加或乘以随机变量。所以基本上我需要从特定的种子中创建一个随机数数组,并且我还需要能够对列表中的每个元素进行数学运算。这是我到目前为止所做的一个例子:
import java.util.Random;
public class{
public static int a [] = new int [101];
public static void main(String[] Args){
for(int i = 0; i <= 100; i++){
Random ran1 = new Random(1337);
a [i] = ran1;//THIS IS THE PROBLEM (incompatible types)
}
int sum = a[5] + a[8] * a[10];//this won't acctually be included, it's just an example
}
}