Java Boolean.equals(Object obj)

Syntax

Boolean.equals(Object obj) has the following syntax.

public boolean equals(Object obj)

Example

In the following code shows how to use Boolean.equals(Object obj) method.


public class Main {
   public static void main(String[] args) {
      Boolean b1 = new Boolean(true);
      Boolean b2 = new Boolean(false);
//from  w w  w.  j a v a 2  s  .  c o  m
      // assign the result of equals method on b1, b2 to res
      boolean res = b1.equals(b2);

      System.out.println("b1:" +b1+ " and b2:" +b2+ " are equal is " + res);
   }
}

The code above generates the following result.





















Home »
  Java Tutorial »
    java.lang »




Boolean
Byte
Character
Class
Double
Enum
Float
Integer
Long
Math
Number
Object
Package
Process
ProcessBuilder
Runnable
Runtime
SecurityManager
Short
StackTraceElement
StrictMath
String
StringBuffer
StringBuilder
System
Thread
ThreadGroup
ThreadLocal
Throwable