Java Reference
In-Depth Information
Depending on the verbosity level, the state of the object is dumped,
adding new output at greater verbosity levels and then printing the out-
put of the next lower level of verbosity:
Verbose v = ... ; // initialized as appropriate
public void dumpState() {
int verbosity = v.getVerbosity();
switch (verbosity) {
case Verbose.SILENT:
break; // do nothing
case Verbose.VERBOSE:
System.out.println(stateDetails);
// FALLTHROUGH
case Verbose.NORMAL:
System.out.println(basicState);
// FALLTHROUGH
case Verbose.TERSE:
System.out.println(summaryState);
break;
default:
throw new IllegalStateException(
"verbosity=" + verbosity);
}
}
Once control has transferred to a statement following a case label, the
following statements are executed in turn, according to the semantics of
those statements, even if those statements have their own different case
labels. The FALLTHROUGH comments in the example show where control
falls through the next case label to the code below. Thus, if the verbosity
 
Search WWH ::




Custom Search