2 dimensional array to string code java
For a program I have to write I am required to turn a 2 dimensional array of single digit intgers into a string of numbers separated by spaces. A test code is provided for me and when I run it, my code fails both arrayToString tests. I am unable to find where my logic error is. Someone help! public static String arrayToString(int[][] a) { String aString; aString = ""; int column; int row; for (row = 0; row < a.length; row++) { for (column = 0; column < a[0].length; column++ ) { aString = aString + " " + a[row][column]; } aString = aString + "\n"; } return aString; }
0 upvotes
View original discussion ↗
Comments
Sign in or sign up to comment and upvote.
No comments yet.