In Java, is there a way to write a string literal without having to escape quotes?
Posted
by Matthew
on Stack Overflow
See other posts from Stack Overflow
or by Matthew
Published on 2010-06-13T22:45:53Z
Indexed on
2010/06/13
22:52 UTC
Read the original article
Hit count: 154
Say you have a String literal with a lot of quotation marks inside it. You could escape them all, but it's a pain, and difficult to read.
In some languages, you can just do this:
foo = '"Hello, World"';
In Java, however, ''
is used for char
s, so you can't use it for String
s this way. Some languages have syntax to work around this. For example, in python, you can do this:
"""A pretty "convenient" string"""
Does Java have anything similar?
© Stack Overflow or respective owner