Skip to content

Commit 1cef2c4

Browse files
authored
Merge pull request #177 from RunestoneInteractive/ternary
hot-fix
2 parents 799f22b + e675e97 commit 1cef2c4

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

source/ch4_conditionals.ptx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,12 +163,12 @@ public class ElseIf {
163163

164164
<p>
165165
Java also supports a <c>switch</c> statement that acts something like the <c>elif</c> or Python <c>match</c> statement under certain conditions. To write the grade program using a <c>switch</c> statement we would use the following:
166-
</p
166+
</p>
167167

168168
<note>
169169
<p>
170170
The <c>match - case</c> statement was introduced in Python 3.10, so doesn't run in earlier version of Python. Here is an example using Python's <c>match - case</c> structure.
171-
</p>
171+
</p></note>
172172
<program xml:id="python-match" language="python">
173173
<title>Match Case Example</title>
174174
<code>
@@ -190,7 +190,6 @@ Java also supports a <c>switch</c> statement that acts something like the <c>eli
190190
print(grading(tempgrade))
191191
</code>
192192
</program>
193-
</note>
194193

195194
<p><idx><c>switch</c></idx>
196195
The <c>switch</c> statement in Java provides an alternative to chaining multiple <c>if-else</c> conditions, when comparing a single variable against several constant values. It supports a variety of data types, including primitive types (<c>byte</c>, <c>short</c>, <c>char</c>, <c>int</c>), their wrapper classes, <c>enumerations</c>, and <c>String</c> (introduced in Java 7). Each <c>case</c> within a <c>switch</c> must be defined using a constant expression, and duplicate <c>case</c> values are not permitted. By default, control flow "<c>falls through</c>" from one <c>case</c> to the next unless a <c>break</c>, <c>return</c>, or <c>throw</c> statement is used to terminate execution.

0 commit comments

Comments
 (0)