F
F
Fedor unknown2020-08-30 18:18:01
Java
Fedor unknown, 2020-08-30 18:18:01

How to fill an array from 275 to 834?

1. There is an array: 2. Given a random number generator: question: How to fill an array with integer values ​​ranging from 275 to 834 inclusive? p.s. what i did:int[] array = new int[15];
int value = random.nextInt(275)+ 559;

Random random = new Random();
        int value = random.nextInt(275)+ 559;
        int[] arrays = new int[15];
        while (arrays.length != value){
            arrays+value;
        }

    }

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey Gornostaev, 2020-08-30
@turdubekov

int[] array = new Random().ints(15, 275, 834).toArray();

T
Timur Pokrovsky, 2020-08-30
@Makaroshka007

while (arrays.length != value)
Why are you comparing the array length (always 15) with a random number (275-834)? The condition will never be false and you will never exit the loop

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question