Compare two Boolean objects
The compareTo method of Boolean wrapper class is used for comparing two Boolean objects.
public class BooleanWrapper {
public static void main(String[] args) {
Boolean b = new Boolean(true);
Boolean b1 = new Boolean(false);
if (b.compareTo(b1) == 0) {
System.out.println("Both objects are equal.");
}
else if (b.compareTo(b1) > 0) {
System.out.println("b is true.");
}
else {
System.out.println("b is false");
}
}
}
Tags: Boolean, Boolean examples, Boolean wrapper class, java.lang, java.lang.Boolean
You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.
Leave a Reply