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 \" \" \""
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.
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: "\\"
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.
charAt(test. length()-1) == 34) { System. out. println("Has double quotes"); } 34 in ascii table represents doublequote , hence it works fine.
No, there is no such option. Sorry.
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