File tree Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Original file line number Diff line number Diff line change @@ -127,10 +127,10 @@ Switch statements are used to execute different code depending on the value of a
127
127
}
128
128
```
129
129
Above is the basic syntax of switch statements. This is how it works:
130
- - The switch expression is evaluated ` once ` .
131
- - The value of the expression is ` compared ` with the values of each case.
132
- - If there is a ` match ` , the associated block of code is executed.
133
- - The ` break ` and ` default ` keywords are optional.
130
+ - The switch expression is only evaluated ` once ` .
131
+ - The value of the expression is ` compared ` with the values of each case value .
132
+ - If there is a ` match ` , ie. the case value and the switch expression are same, the associated block of code with the case value is executed.
133
+ - The ` break ` and ` default ` keywords are optional and will be explained ahead .
134
134
135
135
Now, let us see a diagramtic workflow of the Java Switch statement for a better understanding.
136
136
@@ -187,7 +187,7 @@ Let us see an example to understand it better.
187
187
Output : Vowel
188
188
```
189
189
#### The 'break' Keyword
190
- - When Java reaches a ` break ` keyword, it breaks out of the switch block.
190
+ - When the Java compiler reaches a ` break ` keyword, it breaks out of the switch block.
191
191
- This will stop the execution of more code and case testing inside the block.
192
192
- Basically it means that When a match is found, and the job is done, there is no need for more testing. Hence we break out of the switch statement.
193
193
You can’t perform that action at this time.
0 commit comments