' \ '-Invalid character constant?

前端 未结 7 1641
夕颜
夕颜 2020-12-19 11:27

I need to do this:

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

    }

I get an error saying: Invalid character constant.

Why? a

7条回答
  •  醉话见心
    2020-12-19 12:02

    The backslash is a special character and it needs to be escaped with another backslash. Like this:

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

提交回复
热议问题