Java Random Int randIntArray(int length)

Here you can find the source of randIntArray(int length)

Description

rand Int Array

License

Apache License

Declaration

public static int[] randIntArray(int length) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

public class Main {

    public static int[] randIntArray(int length) {
        int array[] = new int[length];
        List<Integer> list = new ArrayList<>();
        for (int i = 0; i < length; i++) {
            list.add(i);/*from ww w.  ja v a2 s  . c o  m*/
        }
        Random random = new Random();
        for (int i = 0; i < length; i++) {
            array[i] = list.remove(random.nextInt(length - i));
        }
        return array;
    }
}

Related

  1. randInt(int n)
  2. randInt(int n)
  3. randInt(int range)
  4. randInt(int range)
  5. RandInt(int x, int y)
  6. randIntArray(int length)
  7. randIntv(double fr, double to)
  8. randLocation(int min, int max)
  9. Random(int a, boolean Zero)