switchThe switch is sometimes classified as a selection statement. The switch statement selects from among pieces of code based on the value of an integral expression. Its form is: [ Add Comment ] 
switch(integral-selector) {
  case integral-value1 : statement; break; 
  case integral-value2 : statement; break;
  case integral-value3 : statement; break;
  case integral-value4 : statement; break;
  case integral-value5 : statement; break;
          // ...
  default: statement;
}
Integral-selector is an expression that produces an integral value. The switch compares the result of integral-selector to each integral-value. If it finds a match, the corresponding statement (simple or compound) executes. If no match occurs, the default statement executes

解决方案 »

  1.   

    switchThe switch is sometimes classified as a selection statement. The switch statement selects from among pieces of code based on the value of an integral expression. Its form is: [ Add Comment ] 
    switch(integral-selector) {
      case integral-value1 : statement; break; 
      case integral-value2 : statement; break;
      case integral-value3 : statement; break;
      case integral-value4 : statement; break;
      case integral-value5 : statement; break;
              // ...
      default: statement;
    }
    Integral-selector is an expression that produces an integral value. The switch compares the result of integral-selector to each integral-value. If it finds a match, the corresponding statement (simple or compound) executes. If no match occurs, the default statement executes
      

  2.   

    The switch statement selects from among pieces of code based on the value of an integral expression.
      

  3.   

    你传入的参数是String,
    而你比较的参数是char,
    当然不行啦!
    如果你想用operator,
    请将static   int precedence(String operator)
    改为static   int precedence(char operator)
    并在传入参数入char型.
      

  4.   

    同意楼上,switch语句不支持字符串
      

  5.   

    我也同意楼上的,switch语句不支持字符串