Zählen Sie in Matrix java wahr
public class CountTrue {
public static void main(String[] args){
boolean[][]mat= {
{false, false,true},
{true, true, false},
};
int counter=0;
for (int row = 0; row <mat.length ; row++) {
for (int col = 0; col < mat[0].length; col++) {
boolean currentElement = mat [row][col];
if (currentElement){
counter++;
}
}
}
System.out.println(counter);
}
}
Breakable Boar