' \ '-Invalid character constant?

前端 未结 7 1627
夕颜
夕颜 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:10

    I got this similar error in Eclipse for Android although for different situation, and I just figured out that in Java you cannot enclose a string (multi-character word) in single quotes. So you need to have like - "sampleword" strings enclosed in double quotes rather than single quote to get rid of such error thought I could just share it here for others to refer..

提交回复
热议问题