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
  • 389
  • 3
  • 17

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,335,956
  • 823
  • 8,931
  • 9,049