create Int Array - Java java.lang

Java examples for java.lang:int Array

Description

create Int Array

Demo Code


//package com.java2s;
import java.util.Random;

public class Main {
    public static Integer[] createIntArray(int size) {
        Integer[] array = new Integer[size];

        for (int j = 0; j < array.length; j++)
            array[j] = j;/*from   ww w  . j  a  v  a  2s  . c  o  m*/

        Random rnd = new Random();
        int r;

        for (int k = array.length - 1; k > 0; k--) {
            r = rnd.nextInt(k);

            Integer c = array[k];
            array[k] = array[r];
            array[r] = c;
        }

        return array;
    }
}

Related Tutorials