Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java String quote delimiter

Is there any way in Java to use a special delimiter at the start and the end of a String to avoid having to backslash all of the quotes within that String?

i.e. not have to do this:

String s = "Quote marks like this \" are just the best, here are a few more \" \" \""
like image 698
Finbarr Avatar asked Dec 20 '10 17:12

Finbarr


People also ask

How do you put quotation marks in a string in Java?

To put quotation marks in a string in Java, use the backslash escape character before the quotation mark like so: \" . Here's how you do it: String myString = "\"Hello World!\ ""; System.

How do you escape a quote from a string in Java?

The double quote character has to be escaped with a backslash in a Java string literal. Other characters that need special treatment include: Carriage return and newline: "\r" and "\n" Backslash: "\\"

What does 2 quotation marks mean in Java?

For instance, in Java a double-quote is a string while a single-quote is a character. Defining char letter = "a" in Java will cause an error in the same way as String s = 'a bunch of letters' will. Always better to use double-quotes when storing strings.

How do I check if string contains double quotes in Java?

charAt(test. length()-1) == 34) { System. out. println("Has double quotes"); } 34 in ascii table represents doublequote , hence it works fine.


1 Answers

No, there is no such option. Sorry.

like image 153
Vladimir Ivanov Avatar answered Sep 22 '22 19:09

Vladimir Ivanov