Dilllllo Dilllllo - 1 year ago 214
Java Question

Illegal Escape Character "\"

i want to get the name at the final of a link so i did that

if( invName.substring(j,k).equals("\")){

so eclipse said String literal is not properly closed by a double-quote

how can i compaire String with this char \

Answer Source

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) == '\\') {...}
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download