Java Boolean.compareTo(Boolean b)

Syntax

Boolean.compareTo(Boolean b) has the following syntax.

public int compareTo(Boolean b)

Example

In the following code shows how to use Boolean.compareTo(Boolean b) method.


public class Main {
    public static void main(String[] args) {
       Boolean boolean1 = new Boolean("true");
       System.out.println(boolean1);/*from w w  w  .  jav  a  2 s.co  m*/
       
       Boolean boolean2 = new Boolean(true);
       System.out.println(boolean2.compareTo(boolean1));
    }
}

The output:





















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