Created
October 6, 2017 19:20
-
-
Save ShawonAshraf/9c102a9035a0fee664f48e7eb097057d to your computer and use it in GitHub Desktop.
2D variable dim array java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Scanner; | |
public class VariableSize2DArray { | |
public static void main(String[] args) { | |
int row, col; | |
Scanner in = new Scanner(System.in); | |
// takes row and col size | |
// now you know the dim of array : row X col | |
row = in.nextInt(); | |
col = in.nextInt(); | |
// create array | |
int[][] array = new int[row][col]; | |
// take input | |
for (int i = 0; i < row; i++) { | |
for (int j = 0; j < col; j++) { | |
array[i][j] = in.nextInt(); | |
} | |
} | |
// done input | |
in.close(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment