Java java.lang Boolean hashCode()
Description Of Boolean: hashCode()
The java.lang.Boolean.hashCode() returns a hash code for this Boolean object.
Boolean.hashCode() method returns the integer 1231 if this object represents true and the integer 1237 if this object represents false.
Code Example Java Boolean
public class BooleanExam {
public static void main(String[] args) {
Boolean x = new Boolean(true);
Boolean y = new Boolean(false);
int i1, i2;
i1 = x.hashCode();
i2 = y.hashCode();
String str1 = "Hash code of " + x + " is " + i1;
String str2 = "Hash code of " + y + " is " + i2;
// print i1, i2 values
System.out.println(str1);
System.out.println(str2);
}
}
ไม่มีความคิดเห็น :
แสดงความคิดเห็น