0

Display all true boolean values

How do I display all True values? public class arg{ public static void main (String[]arg){ boolean[] correct= new boolean[6]; correct[0]= true; correct[2]= true; correct[3]= false; correct[4]= true; correct[5]= false; } } Output: 3

7th May 2020, 9:16 AM
Christian Campos (Eric)
Christian Campos (Eric) - avatar
1 Resposta
0
Declare a count variable. Run a for loop. Check if correct[i] == true. If true then increment the count. Print the count at the end.
7th May 2020, 9:21 AM
Avinesh
Avinesh - avatar