23.11.2014 Views

Data Structures and Algorithms in Java[1].pdf - Fulvio Frisone

Data Structures and Algorithms in Java[1].pdf - Fulvio Frisone

Data Structures and Algorithms in Java[1].pdf - Fulvio Frisone

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

System.out.pr<strong>in</strong>tln("This is tough.");<br />

break;<br />

case TUE:<br />

System.out.pr<strong>in</strong>tln("This is gett<strong>in</strong>g better.");<br />

break;<br />

case WED:<br />

System.out.pr<strong>in</strong>tln("Half way there.");<br />

break;<br />

case THU:<br />

System.out.pr<strong>in</strong>tln("I can see the light.");<br />

break;<br />

case FRI:<br />

System.out.pr<strong>in</strong>tln("Now we are talk<strong>in</strong>g.");<br />

break;<br />

default:<br />

System.out.pr<strong>in</strong>tln("Day off ! ");<br />

break;<br />

}<br />

The switch statement evaluates an <strong>in</strong>teger or enum expression <strong>and</strong> causes<br />

control flow to jump to the code location labeled with the value of this expression.<br />

If there is no match<strong>in</strong>g label, then control flow jumps to the location labeled<br />

"default." This is the only explicit jump performed by the switch<br />

statement, however, so flow of control "falls through" to other cases if the code<br />

for each case is not ended with a break statement (which causes control flow to<br />

jump to the next l<strong>in</strong>e after the switch statement).<br />

1.4.2 Loops<br />

53

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!