I need to print a 2d array in which I will be giving the values for the row and column at run time.
package test;
import java.util.Scanner;
public class test1 {
    
    public static void main(String[] args) {
        Scanner scan=new Scanner(System.in);
        int rowsize=scan.nextInt();
        int i=0;int j=0;
        int rowarr[]=new int[rowsize];
        int colsize=scan.nextInt();
        int colarr[]=new int[colsize];
        int d[][]=new int[rowsize][colsize];
        for( i=0;i<rowarr.length;i++) {
            rowarr[i]=scan.nextInt();
        }
        
        for( j=0;j<colsize;j++) {
            colarr[j]=scan.nextInt();
        }
        
        for(int k=0;k<rowarr.length;k++) {
            for(int m=0;m<colarr.length;m++) {
                System.out.print(d[rowarr[k]][colarr[m]]);
            }
            System.out.println();
        }
    }
}
I'm getting an error in last line while printing d[rowarr[k]][colarr[m]]. Could anyone provide suggestions?
 
     
     
     
    