【发布时间】:2015-11-20 10:29:15
【问题描述】:
与 if-else if 语句相比,我对“嵌套 if-else 语句”的含义感到困惑。
以下问题要求使用它而不是 if-else 语句,但我不知道如何使用。非常感谢您的帮助!
if (playerThrow == ROCK && computerThrow == ROCK) {
System.out.println("Its a draw!");
} else if (playerThrow == ROCK && computerThrow == PAPER) {
System.out.println("Computer wins!");
} else if (playerThrow == ROCK && computerThrow == SCISSORS) {
System.out.println("Player wins!");
Code is from my textbook (I messed up), else I would have posted mine, sorry
【问题讨论】:
-
这是一个菜鸟问题
-
曾经@Drew 我们都是菜鸟...
-
嗨,欢迎来到 SO!你能稍微编辑一下你的问题吗?我们(大部分时间)不接受“codn-mages”。请直接写到问题中。此外,链接可能会随着时间的推移而中断,因此最好仅将它们用作参考。无论如何,我们在这里为您提供帮助;)。
-
@KemyLand 我会感谢你的
-
@Drew:呵呵,我写的是“codn-mages”,但它是“code-images”...
标签: if-statement language-agnostic nested