A good answer might be:
Give me a break.
We will get to those other rules shortly.
Here is the previous example, with more explanation:
// Usually code would be read in
char code = 'B' ;
switch ( code )
discount = 0.0;
discount = 0.1;
discount = 0.2;
discount = 0.3;
System.out.println( "discount is: "
+ discount );
integerExpression is evaluated.
- In this example, the expression is the variable,
which evaluates to the character 'B'.
- The case labels are inspected starting with the first.
- The first one that matches is
- The corresponding
statementList starts executing.
- In this example, there is just one statment.
- The statement assigns 0.1 to .
break statement is encountered.
- The statement after the
switch statment is executed.
- In this example, the
If code is 'W' what is discount?