Fastest way to check if an array of boolean contains true

后端 未结 7 904
余生分开走
余生分开走 2021-01-12 04:08

I have an array of boolean entries:

boolean[] myBooleanArray = new boolean[24];

Currently i check if it contains

7条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-12 04:45

    If you had an array of 0's and 1's, you could simply OR every element. If you get a 1, you know there is atleast one TRUE.

提交回复
热议问题