Answer the question
In order to leave comments, you need to log in
How to make a construction that checks that if all variables in the boolean array are equal to false then do something....?
How to make a construction that checks that if all variables in a boolean array are equal to false, then do this for example:
Toast toast = Toast.makeText(getApplicationContext(), answer , Toast.LENGTH_SHORT);
toast.setGravity(Gravity.TOP, 0, 15);
toast.show();
Answer the question
In order to leave comments, you need to log in
Feel free to stream.
Boolean[] array = new Boolean[] {false, false, false};
boolean allFalse = Arrays.stream(array).allMatch((e) -> !e);
// или
allFalse = Arrays.stream(array).noneMatch((e) -> e);
If there are few of them, and speed is not important, you can do this:
public static void main(String[] args) {
Boolean[] array = new Boolean[3];
array[0] = true;
array[1] = true;
array[2] = true;
boolean allTrue = !Arrays.asList(array).contains(Boolean.FALSE);
System.out.println(allTrue);
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question