java - Storing twodimensional array into single dimensional array -


please me fix this. want store 2 dimensional array single dimensional array possible. i'm trying have store 2 dimensional integer array created dynamically.

try this:

int[][] arr = new int[rows][cols]; int[] arr1d= new int[rows * cols];  rows = arr.length; if (rows > 0) {     cols = arr[0].length; } else {     cols = 0; }  (int row = 0, count = 0; row < rows; row++) {     (int col = 0; col < cols; col++) {         arr1d[count] = arr[row][col];         count++;     } } 

Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -