How To Create A 2d Array In Java

[Solved] How To Create A 2d Array In Java | Scala - Code Explorer | yomemimo.com
Question : How to initialize a 2d array in Java?

Answered by : samer-saeid

int[][] a = { {1, 2, 3}, {4, 5, 6, 9}, {7},
};

Source : | Last Update : Mon, 30 May 22

Question : 2d array java

Answered by : evan-keegan-donnelly

char[][] array = new int[rows][columns];

Source : | Last Update : Fri, 29 May 20

Question : 2d array java

Answered by : repulsive-rhinoceros-vb989l9rlwsr

 int[][] arr = new int[10][20]; arr[0][0] = 1; 

Source : | Last Update : Sat, 30 Jan 21

Question : define 2d array in java

Answered by : paresh-vasani

const testMatrix = [ [1, 1, 1, 0, 0], [1, 1, 1, 0, 1], [0, 1, 0, 0, 1], [0, 0, 0, 1, 1]
];
const directions = [ [-1, 0], //up [0, 1], //right [1, 0], //down [0, -1] //left
]
const numberOfIslands = function(matrix) { if(matrix.length === 0) return 0; let islandCount = 0; for(let row = 0; row < matrix.length; row++) { for(let col = 0; col < matrix[0].length; col++) { if(matrix[row][col] === 1) { islandCount++; matrix[row][col] = 0; const queue = []; queue.push([row, col]); while(queue.length) { const currentPos = queue.shift(); const currentRow = currentPos[0]; const currentCol = currentPos[1]; for(let i = 0; i < directions.length; i++) { const currentDir = directions[i]; const nextRow = currentRow + currentDir[0]; const nextCol = currentCol + currentDir[1]; if(nextRow < 0 || nextRow >= matrix.length || nextCol < 0 || nextCol >= matrix[0].length) continue; if(matrix[nextRow][nextCol] === 1) { queue.push([nextRow, nextCol]); matrix[nextRow][nextCol] = 0; } } } } } } return islandCount;
}

Source : | Last Update : Sat, 02 Apr 22

Answers related to how to create a 2d array in java

Code Explorer Popular Question For Scala