Hey guys,
do you know why the input is in String, instead of int?
1) Does it need to be a String here (or could the provide an int, too), or why did Codegym give us Strings instead of ints as input?
2) Is it bad practice to use an if, to check if the number is positive here?
2.1) Why don't we need to check that in this case?
Thank you for your time and efforts, and have a great Sunday ahead! :)
package en.codegym.task.pro.task05.task0511;
import java.util.Scanner;
/*
Creating a two-dimensional array
*/
public class Solution {
public static int[][] multiArray;
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int r = Integer.parseInt(scanner.nextLine());
if (r > 0) {
multiArray = new int[r][];
for (int i = 0; i < r; i++) {
int newI = Integer.parseInt(scanner.nextLine());
multiArray[i] = new int[newI];
}
}
}
}