'\' - Investment symbol constant?

I need to do this:

while (result2.charAt(j)!='\'){

    }

I get an error: Invalid character constant.

Why? and how can i overcome it?

+5
source share
7 answers

A backslash is a special character and must be reset using another backslash. Like this:

while (result2.charAt(j)!='\\'){

}
+8
source

Use '\\'. This is because the backslash is used in the escape sequence, for example '\n'. With one, the \compiler has no way to find out.

+2
source

, .

while (result2.charAt(j)!='\\'){

    }
+1

, ,

,

while(results2.charAt(j)!='\\')
{
}

, , ,

0

'\'

" " " == " \" "


" \ " == " \\ "
0

Eclipse Android, , , Java ( ) . - "sampleword" , , , , , .

0

, Unicode.

005C - . : "\ u005C".

:

str = str.replace("\\u005C", "'\\u005C'");
0

All Articles