java - how would you format this to string -


i have

public string tostring() {     string s = "";     (int r = 0; r != 7 ; r++)     {         (int c = 0; c != 7 ; c++)          {             s += string.format("%02d " ,board[r][c]);         }     }     return s; } 

and need return this

01 04 39 20 53 06 37 22
40 19 02 05 38 21 52 07
03 46 61 00 57 54 23 36
18 41 56 49 60 00 08 51
47 14 45 58 55 50 35 24
42 17 48 27 00 59 32 09
13 28 15 44 11 30 25 34
16 43 12 29 26 33 10 31

how can that?

your adding space ever line never new line char

public string tostring() {     string s = "";     (int r = 0; r != 7 ; r++)     {         (int c = 0; c != 7 ; c++)          {            s += string.format("%02d " ,board[r][c]);         }         s += string.format("%n");     }         return s; } 

%n platform independent new line char


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -