Java array fill random number

Description

Java array fill random number

import java.util.Arrays;
import java.util.Random;

public class Main {


  public static void main(String args[]) {
    int[] anArray = new int[10];
    Random rand = new Random();
    /*from w w  w  .j  a  v a2  s.  c o  m*/
    for (int i = 0; i < 10; i++) {
      anArray[i] = rand.nextInt();
    }
    
    System.out.println(Arrays.toString(anArray));
  }

}



PreviousNext

Related