Does Java have the ‘@’ character to escape string quotes?

My string has double quotes in it, in C# I would do:

string blah = @"this is my ""text";

how would I do that in Java?

Answer

No. Such a feature is not available in Java.
From the Sun docs:

When an escape sequence is encountered in a print statement, the compiler interprets it accordingly. For example, if you want to put quotes within quotes you must use the escape sequence, “, on the interior quotes. To print the sentence

She said "Hello!" to me.

you would write

System.out.println("She said "Hello!" to me.");

Leave a Reply

Your email address will not be published. Required fields are marked *