The countTrue() method of Booleans Class in Guava Library is used to count the number of values that are true in the specified boolean values passed as the parameter.
public static int countTrue(boolean... values)
Parameters: This method accepts the boolean values among which the true values are to be count.
Return values: This method returns an integer value which is the count of values that are true.
Example 2 :
Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course.