create Int Array via Array.newInstance - Java java.lang

Java examples for java.lang:int Array

Description

create Int Array via Array.newInstance

Demo Code


//package com.java2s;
import java.lang.reflect.Array;

public class Main {
    public static void main(String[] argv) throws Exception {
        int rows = 2;
        int cols = 2;
        System.out.println(java.util.Arrays.toString(createIntArray(rows,
                cols)));/*from  w w  w .  j a v a  2  s.  c o  m*/
    }

    public static int[][] createIntArray(int rows, int cols) {
        return (int[][]) Array.newInstance(int.class, rows, cols);
    }
}

Related Tutorials