Why it index out of bound?
I nap a picture in ---> PICTURE
Code:
Scanner sc = new Scanner(System.in);
int a=0,b=0,n=0;
int[][] sum;
int q = sc.nextInt();
for(int i=0;i<q;i++){
a = sc.nextInt();
b = sc.nextInt();
n = sc.nextInt();
sum = new int[i][n];
sum[i][0] = a + (int)Math.pow(2,0) * b;
focus on this
sum = new int[i][n];
sum[i][0] = a + (int)Math.pow(2,0) * b;
Input:
1
5 3 5
Exception:
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: Index 0 out of bounds for length 0
at Main.main(Main.java:19)