I have a code like,
String str = \" \" ; while( cond ) { str = str + \"\\n\" ; }
Now, I don\'t know why at the time of printing, the out
The newline character is considered a control character, which doesn't print a special character to the screen by default.
As an example, try this:
String str = "Hi"; while (cond) { str += "\n"; // Syntactically equivalent to your code } str += "Bye"; System.out.println(str);