Boolean.logicalAnd() method in Java

logicalAnd() method performs the logical AND operation between two boolean values. This post will discuss the logicalAnd() method of the Boolean wrapper class in detail.

  • Method declaration – public static boolean logicalAnd(boolean a, boolean b)
  • What does it do? logicalAnd() method takes two boolean arguments and performs the logical AND operation on them.
  • What does it return? It will return the final value after performing the logical AND operation.
Internal implementation of the logicalAnd() method
    public static boolean logicalAnd(boolean a, boolean b) {
        return a && b;

Below are the combinations that can be passed in the logicalAnd() method and the corresponding value it will return.

logicalAnd() method combinations
Code Example
public class Codekru {

	public static void main(String[] args) {

		System.out.println("value 1: " + Boolean.logicalAnd(true, true));
		System.out.println("value 2: " + Boolean.logicalAnd(true, false));
		System.out.println("value 3: " + Boolean.logicalAnd(false, true));
		System.out.println("value 4: " + Boolean.logicalAnd(false, false));

Output –

value 1: true
value 2: false
value 3: false
value 4: false
Time Complexity of the logicalAnd() method

As logicalAnd() method only performs the AND operation between two boolean values. So, the time complexity of the logicalAnd() method is O(1).

Please visit this link to learn more about the Boolean wrapper class of java and its other functions or methods.

We hope that you have liked the article. If you have any doubts or concerns, please feel free to write us in the comments or mail us at

Liked the article? Share this on

Leave a Comment

Your email address will not be published. Required fields are marked *