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
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
解决方案 »
- 用threadPoolExecutor做线程池,但每次都要新建一个runable对象?
- String 里的 toString() 方法有什么用么? 大家看我说的对不??
- 组合框,数据模型,显示!
- 在jEditorPane跟jTextPane中显示html界面很乱
- 大家好,能帮我看下这段jsp代码用”response.setContentType“为什么改变不了ContentType的属性值
- 重开一贴继续求教,如何替换掉不是关键字的if
- 问一句,jsp语句?
- 急!关于access字符问题
- java设计高手请进入讨论异常处理
- 请问JAVA里有没有类似与C语言中的include *.h语句??
- Java初学,在线等待,高分相送,也许简单,HelloWold为何运行不起来?没事也可来看看啊*^o^*
- 原来还可以编译的 现在却不行了 提示如下:
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
而你比较的参数是char,
当然不行啦!
如果你想用operator,
请将static int precedence(String operator)
改为static int precedence(char operator)
并在传入参数入char型.