Compare two Boolean Arrays in Java

The Boolean arrays in Java stores Boolean datatypes i.e. the boolean values, TRUE and FALSE. To compare two boolean array, Java has a built-in method Arrays.equal(). It checks for the equality of two arrays.

Syntax

Above, returns TRUE if both the arrays are equal.

The method Arrays.equals() compares in the basis of count of elements and the corresponding pairs of elements.

Let us see some examples to compare Boolean arrays;

Example 1

Output

Example 2

Let us now see another to compare two Boolean arrays, in which the arrays are same, but the order is different:

Output

Java Program for String representation of Boolean
Java Program to convert integer to boolean
Studyopedia Editorial Staff
Studyopedia Editorial Staff
[email protected]

We work to create programming tutorials for all.

No Comments

Post A Comment

Discover more from Studyopedia

Subscribe now to keep reading and get access to the full archive.

Continue reading