Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public int[][] getInt2DArray(String str) {
- String[] arrStr = str.split(" ");
- int arrLength = arrStr.length;
- int size = (int) Math.sqrt(arrLength);
- int[][] arrInt = new int[size][size];
- for (int i = 0; i < size; i++) {
- for (int j = 0; j < size; j++) {
- arrInt[i][j] = Integer.parseInt(arrStr[j+i*size]);
- }
- }
- return arrInt;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement