| default |
|
grammar |
| |
A flow control statement whose valid context is only within a
switch
statement.
Control passes to the statements following this statement whenever there
is no other statement within the
switch
statement that satisfies an
equality relationship with the
switch
statement argument.
When control falls to the
default
statement,
the first
break
statement encountered in the same context
marks the end of statements to be executed.
Its usage description can be summarized as follows:
Statement:
default :
| |
| Example: |
This example shows a
default
in action:
String candidate = "Bush";
switch(candidate) {
case "Wilson":
case "Roosevelt":
case "Truman":
case "Kennedy":
case "Johnson":
case "Carter":
case "Clinton":
stdout.nextline = "A match!";
break;
default:
stdout.nextline = "Not a match!";
break;
}
with the result:
Not a match!
| | |
| See Also: |
break,
case,
reference,
switch
|
|
Yoix is a registered trademark of AT&T Intellectual Property.
|