samedi 4 avril 2015

Store in an array instead of printing out?

Hi I have the following code. Instead of printing it out to the counsel I want to store the resulted prints in an array. How would I do it?



static void printPaths (String tempString, int i, int j, int m, int n, char [][] arr) {
String newString = tempString + arr[i][j];
if (i == m -1 && j == n-1) {
System.out.println(newString);
return;
}
//right
if (j+1 < n) {
printPaths (newString, i, j+1, m, n, arr);
}
//down
if (i+1 < m) {
printPaths (newString, i+1, j, m, n, arr);
}
}

Aucun commentaire:

Enregistrer un commentaire