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?
Yes* (since September 2019) but it used different sintax. “”” (three double-quote marks).
*In more recent java versions (+13 in preview, +15 as production ready), mostly equivalent can be achieved with the java text blocks.
String html = """
<xml>
<ody>
<pan>example xml </pan>
</ody>
</xml>""";
https://docs.oracle.com/en/java/javase/13/text_blocks/index.html
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.");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With