I want to get the name at the end of a link so I did that
if( invName.substring(j,k).equals("\")){
copyf=invName.substring(0,j);}
Eclipse said String literal is not properly closed by a double-quote
How can I compare String with this char \
?
The character '\' is a special character and needs to be escaped when used as part of a String, e.g., "\". Here is an example of a string comparison using the '\' character: if (invName. substring(j,k).
Generally speaking, when the compiler gives you an error message, it tells you more than just "illegal escape character". It will show you the line and even the exact spot it thinks the error actually is: ? It GREATLY helps people help you if you post the ENTIRE message.
It is a term related to that of an escape sequence and an Esc (escape) key. The character itself isn't "running away" from any other character.
Escape Characters When you use braces to escape a single character, the escaped character becomes a separate token in the query. \ Use the backslash character to escape a single character or symbol. Only the character immediately following the backslash is escaped.
The character '\' is a special character and needs to be escaped when used as part of a String, e.g., "\". Here is an example of a string comparison using the '\' character:
if (invName.substring(j,k).equals("\\")) {...}
You can also perform direct character comparisons using logic similar to the following:
if (invName.charAt(j) == '\\') {...}
Use "\\"
to escape the \ character.
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