Waveprint challenge

while running the code this error is coming hlp ASAP

Exception in thread “main” java.util.NoSuchElementException
at java.util.Scanner.throwFor(Scanner.java:862)
at java.util.Scanner.next(Scanner.java:1485)
at java.util.Scanner.nextInt(Scanner.java:2117)
at java.util.Scanner.nextInt(Scanner.java:2076)
at Main.main(Main.java:14)

@Naman_Gupta,

https://ide.codingblocks.com/s/254175 Corrected code.

Here i should be arr.length and j should be arr[0].length. Not every test case will be a square matrix.

Also, the best way to debug your code for matrix pattern printing is to use the testcase:
2 3
1 2 3
4 5 6

i understand that not every matrix is a square so i use the usual approach of the video which is more efficient for any rowno and columnno

@Naman_Gupta,
Yeah that works too. :smile:

@Naman_Gupta,

But in a matrix the size of the columns remains consistent with every row. So you need not take input for number of columns in every row.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.