can you have two conditions in an if statement

后端 未结 6 1520
鱼传尺愫
鱼传尺愫 2020-12-22 13:48

I\'m a beginner in coding. I was recently working with to create a chatting programme where a user will chat with my computer. Here is a part of the code:

Sy         


        
6条回答
  •  庸人自扰
    2020-12-22 14:15

    Here are some common symbols used in everyday language and their programming analogues:

    • "," usually refers to "and" in everyday language. Thus, this would translate to the AND operator, &&, in Java.
    • "/" usually refers to "or" in everyday language. Thus, this would translate to the OR operator, ||, in Java.

    "XOR" is simply "x || y but both cannot be true at the same time". This translates to x ^ y in Java.

    In your code, you probably meant to use "or" (you just used the incorrect "incorrect solution" :p), so you should use "||" in the second code block for it to become identical to the first code block.

    Hope this helped :)

提交回复
热议问题