`// This rule specifies whether a switch statement has
// to have a default statement. In the case that no
// case statement is true and a default statement exists,
// this one is used. Usually a switch should always have
// a hit and it is an error if no case statement is valid.
// If this rule is enabled, each switch statement must
// have a default statement.
// switch with no default
...
switch (alarmStatus)
{
case KITCHEN:
triggerKitchenAlarm();
break;
case BEDROOM:
triggerBedroomAlarm();
break;
case LIVINGROOM:
triggerLivingRoomAlarm();
break;
// a non hit is not shown
}
// switch with default
...
switch (alarmStatus)
{
case KITCHEN:
triggerKitchenAlarm();
break;
case BEDROOM:
triggerBedroomAlarm();
break;
case LIVINGROOM:
triggerLivingRoomAlarm();
break;
default:
// shows an abnormal situation to developer/user
System.err.println("An unknown alarm was triggered: " +
alarmStatus);
break;
}
`