Dilllllo Dilllllo - 3 months ago 37
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 \


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) == '\\') {...}