Java array fill random number within a range
import java.util.Arrays; import java.util.Random; public class Main { public static void main(String[] args) { int[] array = new int[10]; Random rand = new Random(); for (int i = 0; i < array.length; i++) { array[i] = rand.nextInt(10);//from w w w .j av a2s .com } System.out.println(Arrays.toString(array)); } }