get Matrix From Array - Java java.lang

Java examples for java.lang:Math Matrix

Description

get Matrix From Array

Demo Code


//package com.java2s;

public class Main {

    public static int[][] getMatrixFromArray(int[] array, int height,
            int width) {
        int[][] matrix = new int[height][width];

        int k = 0;
        for (int i = 0; i < height; i++)
            for (int j = 0; j < width; j++) {
                matrix[i][j] = array[k];
                k++;/*from  w  w  w .j  a v a  2 s.c o m*/
            }

        return matrix;
    }
}

Related Tutorials