I have a string.
String invalid = "backslash escaping as <>:;%+\/"."
I received an error message telling me to add \ to escape the sequence.
When I try to write this in Java I know that backslash needs to be escaped as \\. So I wrote it as:
String invalid = "backslash escaping as <>:;%+\\/\"."
Now this displays as backslash escaping as <>:;%+\\/".
The backslash is not escaping. How do I get only one backslash?
I don’t find a problem with your modification. This runs as expected:
In your first example, you have a little problem:
Which I believe should be like this:
Because in the first way, you are closing the string before you want to. The part
."is out of the String.Edit:
try writing the output to a file or to a JTextField or something and see what happens, your string is correct and if you compare your output with my output it is the same. It might be an issue with your debugger (weird, but possible).