0

In C#, there's a way to tell the compiler to interpret a string literally, without consideration of escape characters.

string myStr = @"Some literal string, \ doesn't need to be escaped";

Is something like this possible in Java?

David Mordigal
  • 399
  • 3
  • 19

1 Answers1

4

What you're referring to in C# is a verbatim string literal, as opposed to a regular string literal like "foo" - both are string literals, just as "foo" is a string literal in Java, too.

No, Java doesn't have any similar feature.

It also doesn't have any equivalent to the string interpolation feature being introduced in C# 6, with "x={x} y={y}" for example.

Jon Skeet
  • 1,421,763
  • 867
  • 9,128
  • 9,194