0

I need to create an array of integers (doubles and floats are fine too but I don't think there is a difference) since I will need to do certain math actions with them such as * and +. I am trying to fill up the array with Random seeds (i.e. 1337 5443, I need to use these) but I can't convert a random variable into a int and I can't add or multiply random variables. So essentially I need to make an array of random numbers from specific seeds and I also need to be able to do math actions with each element of the list. Here is an example of what I have done so far:

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
    }
}
rgettman
  • 176,041
  • 30
  • 275
  • 357
Nick Zoum
  • 13
  • 2

1 Answers1

5

You don't assign a Random to an int -- you need to call nextInt, passing a int that gives the range between 0 and that bound minus 1.

a[i] = ran1.nextInt(10);  // 0-9 or substitute what you want for 10
rgettman
  • 176,041
  • 30
  • 275
  • 357
  • so what do i insert in the () of nextInt – Nick Zoum Dec 05 '14 at 01:12
  • 1
    That depends on the intended range of random numbers you want to produce. If you want numbers in the range 0-9, choose `10`. If you want `0-99`, choose `100`. If you want an arbitrary range, then please see [Generating random integers in a range with Java](http://stackoverflow.com/questions/363681/generating-random-integers-in-a-range-with-java). – rgettman Dec 05 '14 at 01:14
  • Closing the question is for questions with problems (unclear, off-topic, etc.). That's not a good thing. But instead you may mark exactly one answer in a question as "accepted", by clicking the check mark next to the answer that you think helped you the most. – rgettman Dec 05 '14 at 01:22