switch语句没有切换

时间:2017-04-07 13:53:19

标签: java switch-statement

我有一个需要阅读的值。该值是我转换为int的十六进制。 我有几个可能的值,但switch语句接受所有情况。

 int messValue = Integer.parseInt(messType,16);
   switch(messValue)
   { 
   case 160 : System.out.println(messType.toUpperCase() + " It's a financial Message request");
   case 161 : System.out.println(messType.toUpperCase() + " It's a financial Message  response");
   case 162 : System.out.println(messType.toUpperCase() + " It's a Reversal message request");
   case 163 : System.out.println(messType.toUpperCase() + " It's a Reversal message Acquirer Repeat");
   case 164 : System.out.println(messType.toUpperCase() + " It's a Reversal message response");
   case 165 : System.out.println(messType.toUpperCase() + " It's a Network message request");
   case 166 : System.out.println(messType.toUpperCase() + " It's a Network message response");
   case 167 : System.out.println(messType.toUpperCase() + " It's a Network message response issuer");
   default : break;
   }

输入为" A0" :

A0 It's a financial Message request
A0 It's a financial Message  response
A0 It's a Reversal message request
A0 It's a Reversal message Acquirer Repeat
A0 It's a Reversal message response
A0 It's a Network message request
A0 It's a Network message response
A0 It's a Network message response issuer

1 个答案:

答案 0 :(得分:2)

在每个最后一个内部案例陈述之后添加break;