I am declaring a 2 d array with column size as zero.while taking the input i am getting array index out of bound exception.I don't understand why?
Scanner s=new Scanner(System.in);
int arr=new int;
then what is the use of creating 2d array?
Please try with int arr=new int;
If you want an array of length one, you should declare it as:
This would create an array that can hold one element, at index 0.
Your code makes use of 0th column so you need to declare one column in the declaration
int arr = new int;
change j<1 to j<0 `
Please login first before posting an answer.