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

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -