java - What happens in system.out.print with empty quotations marks and no String assignment? -


i'm reading "head first java". code below 1 of exercises. idea figure out possible output.

there's 1 thing don't understand however.

within system.out.print couple of empty quotations used thought quotations used strings , in code example below there no strings? doing here, how should read it?

class test {     public static void main(string[] args) {         int x = 0;         int y = 0;         while ( x < 5 ) {             y = x - y;             system.out.println(x + "" + y + " " );             x = x + 1;          }     } }   

i can't sure of idea of guy whi make course, + "" + can avoid addition of 2 ints, in fact if concatenate instead of addition 2 ints :

system.out.println(x + "" + y + " " ); 

for example :

  • x + "" + y : going print 00 11 21 32 42 (with new lines of course between each)

  • x + y : going print 0 2 3 5 6 (with new lines of course between each)


Comments

Popular posts from this blog

html - How to set bootstrap input responsive width? -

javascript - Highchart x and y axes data from json -

javascript - Get js console.log as python variable in QWebView pyqt -