' \ '-Invalid character constant?

前端 未结 7 1621
夕颜
夕颜 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:00

    Use '\\'. It's because backslash is used in escape sequence like '\n'. With a single \ the compiler have no way to know.

提交回复
热议问题