Code 2 in generated java classes

As I said in “Code 1 in generated java classes” there is another code snippet I would like to get some information about:

private boolean __hashCodeCalc = false;
    public synchronized int hashCode() {
        if (__hashCodeCalc) {
            return 0;
        }
        __hashCodeCalc = true;
        int _hashCode = 1;
        if (getCurrencyCode() != null) {
            _hashCode += getCurrencyCode().hashCode();
        }
        if (getAnnualSalary() != null) {
            for (int i=0;
                 i<java.lang.reflect.Array.getLength(getAnnualSalary());
                 i++) {
                java.lang.Object obj = java.lang.reflect.Array.get(getAnnualSalary(), i);
                if (obj != null &&
                    !obj.getClass().isArray()) {
                    _hashCode += obj.hashCode();
                }
            }
        }
        if (getAnnualBonus() != null) {
            for (int i=0;
                 i<java.lang.reflect.Array.getLength(getAnnualBonus());
                 i++) {
                java.lang.Object obj = java.lang.reflect.Array.get(getAnnualBonus(), i);
                if (obj != null &&
                    !obj.getClass().isArray()) {
                    _hashCode += obj.hashCode();
                }
            }
        }
        __hashCodeCalc = false;
        return _hashCode;
    }

Best regards Dago

Hi again,
In order for Java Collections to work properly, the equals() and hashCode() methods on your Object must be compatible. Compatible means that if equals() reports that two instances are the same, then the hashCode() of both instances must return the same value. An object’s HashCode is just a numeric value that can be used to store and index the object in a Hashtable (for example). So in the example you have given, both the equals and the hashCode methods have been overriden to use the currency, salary and bonus properties of the object. There’s more detail here Yahoo | Mail, Weather, Search, Politics, News, Finance, Sports & Videos
Best regards
Bill

:D:D:D
Again thanks a lot for your help.

Dago