簡單記錄一下 Boolean compare 的結果

簡單記錄一下 Boolean compare 的結果

Boolean a1 = true;
Boolean a2 = false;
System.out.println("true compareTo false : " + a1.compareTo(a2));
System.out.println("false compareTo true : " + a2.compareTo(a1));
a2 = true;
System.out.println("true compareTo true : " + a2.compareTo(a1));
a1=false;
a2=false;
System.out.println("true compareTo true : " + a2.compareTo(a1));

輸出結果:

true compareTo false : 1
false compareTo true : -1
true compareTo true : 0
true compareTo true : 0

Related Posts