Using straight up java we will count the number of booleans in a list by using an enhanced for each looping over the collection while maintaining a count of the number of elements that equal true.
Java 8 introduced reduction operations which return one value by combing the contents of a stream. Below, we will use a lambda expression to filter elements that equal to true then call the Stream.count to count the number of booleans that exist in the stream.
Using guava Booleans utility class we will call Booleans.countTrue which accepts an array and returns the number of the values equaling true.
Apache commons CollectionUtils.countMatches will count the number of elements that match the provided predicate, in this case that will evaluate to true.