There are a few of these topics out there, but this problem has a slight twist that makes it different.
I\'m focused on only half of a larger problem. I\'m sure man
First, test out the Scanner results. I don't think those delimiters will work. (BTW, Scanner's nextInt()
method is handy.)
If you can assume the input is a square matrix, scanning the first line will reveal how many integers it contains. Then you can (re)allocate the arrays. Then process all the lines, including the first line that you already scanned.
Then you can set matrix = new int[n][n];