When I create this String:
private String chars = " `~1!2@3#4$5%6^7&8*9(0)-_=+qQwWeErRtTyYuUiIoOpP[{]}\|aAsSdDfFgGhHjJkKlL;:'"zZxXcCvVbBnNmM,<.>/?";
Eclipse tells me:
Invalid escape sequence (valid ones are \b \t \n \f \r \" \' \\ )
How do I fix this?
The
\is an escape character. You’re basically escaping|which doesn’t need to be escaped at all. If you want to represent an\in String, then you need to let it escape itself.Please note that the
"does need to be escaped, otherwise the string value ends too early and the code still won’t compile due to all the odd characters thereafter.