Java Reference
In-Depth Information
System.out.println("Out of switch "
+ "structure.");
//Line 30
}
}
Sample Runs
These outputs were obtained by executing the preceding program several times. In each
of these outputs, the user input is shaded.
Sample Run 1:
4
Enter an integer between 0 and 10: 0
The number you entered is 0
Hello there. I am Mickey.
Out of switch structure.
Sample Run 2:
Enter an integer between 0 and 10: 3
The number you entered is 3
I am Mickey.
Out of switch structure.
Sample Run 3:
Enter an integer between 0 and 10: 4
The number you entered is 4
Mickey.
Out of switch structure.
Sample Run 4:
Enter an integer between 0 and 10: 7
The number you entered is 7
are you?
Out of switch structure.
Sample Run 5:
Enter an integer between 0 and 10: 9
The number you entered is 9
Out of switch structure.
A walk-through of this program, using certain values of the switch expression num , can
help you understand how the break statement functions. If the value of num is 0 ,
the value of the switch expression matches the case value 0 . All statements following
case 0: execute until a break statement appears.
Search WWH ::




Custom Search