Created
May 2, 2020 11:15
-
-
Save olegrewko/755782dd2d3566095e11f0cd9eedefac to your computer and use it in GitHub Desktop.
Генератор случайных чисел
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package IgorDolgov; | |
import java.util.Arrays; | |
import java.util.Random; | |
public class RandomArrayGenerator { | |
public static void main (String[] args) { | |
//Метод randomArrayGenerator(n, m); выводит n-ое кол-во случайных чисел от 0 до m | |
int[] array = randomArrayGenerator(1, 350); | |
System.out.println(Arrays.toString(array)); | |
} | |
private static int[] randomArrayGenerator (int arrayLength, int upperBound) { | |
int[] array = new int[arrayLength]; | |
Random random = new Random(); | |
for (int i = 0; i < array.length; i++) { | |
array[i] = random.nextInt(upperBound); | |
} | |
return array; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment