Line break in BlueJ not working (\n \r\n)

244 views Asked by At

I am trying to add a line break in blueJ but it won't work since the return type of String will return the literal character. I have tried both \r\n and \n same result.

public String testNl() {
  String str1 = "1st Line";
  String str2 = "text 2nd";
       
  String linebreak = str1 + "\n" + str2;
       
  return linebreak;
}

Result: 1st Line\ntext 2nd

0

There are 0 answers