0

In c#, @ sign is used before string literals to change how the compiler parses the string. Is there a counterpart of this in java? Using concatenation confuses me sometimes.

Rjmr
  • 19
  • 9

1 Answers1

0

Strings cannot be on multiple lines in java. Your editor may automatically wrap them, but the string itself cannot be on multiple lines - that is, don't hit enter in the middle of a string literal.

If you want your string to contain a new line, use \n ex

System.out.println("Line 1\nLine 2");

results in

Line 1
Line 2
Jon Takagi
  • 101
  • 3
  • thanks for the advice dude. but what i wanted in my program is that i don't want any + signs because sometimes it confuses me and i hit enter in the middle of the string literal. – Rjmr Dec 16 '14 at 09:10
  • ah. Java can't really deal with that without concatenating them, like you said. – Jon Takagi Dec 16 '14 at 09:12
  • Fortunately, the compiler will catch it for you. – Jon Takagi Dec 16 '14 at 09:13