0

I have a value that needs to be read. The value is a Hex that I convert to int. I have several possible values but the switch statement accept all cases.

 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;
   }

here's the output when the input is "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
YGouddi
  • 341
  • 2
  • 14

1 Answers1

2

Add break; after every last inner case statement

ZhenyaM
  • 676
  • 1
  • 5
  • 15