Java Switch Statement - Is “or”/“and” possible?

前端 未结 5 1797
说谎
说谎 2020-12-14 05:24

I implemented a font system that finds out which letter to use via char switch statements. There are only capital letters in my font image. I need to make it so that, for ex

5条回答
  •  时光取名叫无心
    2020-12-14 05:43

    Above, you mean OR not AND. Example of AND: 110 & 011 == 010 which is neither of the things you're looking for.

    For OR, just have 2 cases without the break on the 1st. Eg:

    case 'a':
    case 'A':
      // do stuff
      break;
    

提交回复
热议问题