Java - OR / AND characters (|| &&) illegal in if-statement

試著忘記壹切 提交于 2019-12-01 06:33:44

The character u00a0 is a non-breaking space.

It seems like you typed a control char in your code, replace everything from a copy of this line

if(!input.equals("yes") && !input.equals("no"))

Or simply suppress the spaces in your line and re-type them (making sure you don't type in nbsp).

Notice that I changed the || to && as typing "no" for example would still enter the condition as "yes" would not equals to input. Your condition would then be true || false which would result in true.

In any case, this is not related to the || or && operator, it is the spaces.

'\u00a0'parses to a non breaking space, so maybe it's not the pipes that are the problem. try eliminating the space around the pipes and enclosing the negated statements in parentheses and see if the error persists.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!