课程: Java Essential Training: Syntax and Structure
今天就学习课程吧!
今天就开通帐号,24,700 门业界名师课程任您挑!
Switch statements
- [Instructor] The switch statement is a decision structure that solves a problem in a similar way that the if-else-if decision structure does. It's ideal for cases when you have more than two paths. The difference between the if-else-if and the switch statement is that if-else-if checks if the condition is true, whereas the switch statement checks for equality. In this example, we'll have a user enter their grade, and then, using a switch statement, print a message based on the student's letter grade. In this new grade message class, we've already asked the user to enter their letter grade, and we've scanned that in, and stored it inside of this grade variable, and we've also declared a variable for message, but we don't know the value of this message just yet. To determine which message to print, we'll use the switch decision structure. In order to invoke this, we type switch, a set of parentheses, and a set of curly…
随堂练习,边学边练
下载课堂讲义。学练结合,紧跟进度,轻松巩固知识。
内容
-
-
-
-
-
-
If statements4 分钟 44 秒
-
(已锁定)
If-else statements3 分钟 5 秒
-
(已锁定)
If-else-if statements4 分钟 22 秒
-
(已锁定)
Switch statements5 分钟 2 秒
-
(已锁定)
Switch expressions3 分钟 3 秒
-
(已锁定)
Relational operators2 分钟 17 秒
-
(已锁定)
Logical operators3 分钟 55 秒
-
(已锁定)
Short circuit logic2 分钟 37 秒
-
(已锁定)
Code Solution: Change for a dollar game1 分钟 4 秒
-
-
-
-
-
-
-