I have a for loop condition in my code as below:
for(int i=0; contactInfoRecordArray[i].get_170_Cntct_Sqn() != 0 && 
             i<contactInfoRecordArray.length ; i++){
    insuranceObjectKey = new Integer(contactInfoRecordArray[i].get_170_Cntct_Insobj_Sqn());
        if(insuranceObjectMap.containsKey(insuranceObjectKey) && insuranceObjectMap.get(insuranceObjectKey) != null) {
            serviceUseMap = (HashMap)(insuranceObjectMap.get(insuranceObjectKey));
        } else {
            serviceUseMap = new HashMap();
            insuranceObjectMap.put(insuranceObjectKey, serviceUseMap);
        }
        //second level (Service eg. Wildfire)
        serviceUseKey = new Integer(contactInfoRecordArray[i].get_170_Cntct_Srvcuse_Sqn());
        if(serviceUseMap.containsKey(serviceUseKey) && serviceUseMap.get(serviceUseKey) != null) {
            contactMap = (HashMap)serviceUseMap.get(serviceUseKey);
        } else {
            contactMap = new HashMap();
            serviceUseMap.put(serviceUseKey, contactMap);
        }
        //third level (ContactAssignmentType)
        contactKey = new Integer(contactInfoRecordArray[i].get_170_Cntct_Sqn());
        if(contactMap.containsKey(contactKey) && contactMap.get(contactKey) != null) {
            contactAssignment = (ContactAssignmentType)contactMap.get(contactKey);
        } else {
            contactAssignment = ContactAssignmentType.Factory.newInstance();
            contactAssignment.setPriority(contactInfoRecordArray[i].get_170_Cntct_Prty_Seq_N());
            contactAssignment.setRole(ServiceEligibilityReferenceDataUtility.getInstance().getContactAssignmentType_Role(contactInfoRecordArray[i].get_170_Cntct_Role_C()));
            ContactType contact = contactAssignment.addNewContact();
            contact.setName(contactInfoRecordArray[i].get_170_Cntct_Na());
            contactMap.put(contactKey, contactAssignment);
        }
        //fourth level (Communication Info)
        if(contactAssignment.getContact().getCommunicationAggregate() != null) {
            communicationAggr = contactAssignment.getContact().getCommunicationAggregate();
        } else {
            communicationAggr = contactAssignment.getContact().addNewCommunicationAggregate();
        }
        CommunicationType communication = communicationAggr.addNewCommunication();
        communication.setPriority(contactInfoRecordArray[i].get_170_Commu_Prty_Seq_N());
        communication.setValue(contactInfoRecordArray[i].get_170_Commu_Dvc_V());
        communication.setUsage(ServiceEligibilityReferenceDataUtility.getInstance().getCommunicationType_Usage(
                contactInfoRecordArray[i].get_170_Commu_Dvc_Loc_Na().trim()));
        communication.setType(
                ServiceEligibilityReferenceDataUtility.getInstance().getCommunicationType_Type(
                        contactInfoRecordArray[i].get_170_Commu_Dvc_Na(), contactInfoRecordArray[i].get_170_Commu_Dvc_Mode_Na()));
} The contactInfoRecordArray.length = 100. Now when value of i reaches 100, I get an Array Out Of bound Exception.
If I reverse the condition in &&, it just works fine - please see code below:
for(int i=0; i<contactInfoRecordArray.length && 
             contactInfoRecordArray[i].get_170_Cntct_Sqn() != 0 ; i++)
I'm not sure why it works. Any insight would be greatly appreciated.
