JAVA evaluating multiple OR conditions in IF statement -
How do I process this statement correctly? Is there a better way?
byte [] buf = rtm.getMessageData (); If (buff [0] == 'A' || 'B' || 'C' || 'D' || 'E' || 'F') < Correct Java will have the exact analog of your code: if (buf [0] ==)
'A' || Buff [0] == 'B' || Buff [0] == 'C' || Buff [0] == 'D' || Buff [0] == 'E' || Buff [0] == 'F')
But as you have guessed, there are better ways.
One option:
if (buf [0]> = 'a' and buf [0] Switch (Buff [0]) {Case 'A': Case 'B ': Case' C ': Case' D ': Case' E ': Case' F ': ... rupture; Default: ...}
Comments
Post a Comment