Code example for BigInteger

Methods: equals, hashCode

0
     * Test hash codes for equal objects. 
     */ 
    public void testEqualObjects() { 
        String value1 = "12378246728727834290276457386374882976782849";
        String value2 = "12378246728727834290276457386374882976782849";
        BigInteger aNumber1 = new BigInteger(value1);
        BigInteger aNumber2 = new BigInteger(value2);
        int code1 = aNumber1.hashCode();
        int code2 = aNumber2.hashCode();
        if (aNumber1.equals(aNumber2)) {
            assertTrue("hash codes for equal objects are unequal", code1 == code2);
        } 
    } 
 
    /** 
     * Test hash codes for unequal objects. 
     * The codes are unequal. 
     */ 
    public void testUnequalObjectsUnequal() { 
        String value1 = "12378246728727834290276457386374882976782849";
        String value2 = "-5634562095872038262928728727834290276457386374882976782849";