Skip to Content
0
Former Member
Oct 29, 2009 at 01:51 AM

Avoid java.lang.IndexOutOfBoundsException error

528 Views

This is the error message:

java.lang.IndexOutOfBoundsException: Index: 3, Size: 3 

    at at java.util.ArrayList.RangeCheck(ArrayList.java:539)
    at at java.util.ArrayList.get(ArrayList.java:356)

Below line of coding is the place where system encounter the error

node.setLeadSelection(j); //this is the place causing the error

             if (!"".equals(wdContext.getCurrentElement()
                 .getAttributeValue((String) contextInputFields.get(c))))
			 {
				 allFieldsEmpty = false;
			} else {
				wdThis.raiseNoAnswersMaintained();
			}
		}

		// if all answer fields are empty then set the question lead selection from 1...n
		if (allFieldsEmpty) {
			// set lead selection of dropdown listboxes from 1...n
			for (int j = 0; j < contextDropDowns.size(); j++) {
				IWDNode node =
					wdContext.getChildNode(
						(String) contextDropDowns.elementAt(j),
						0);
				node.setLeadSelection(j); //this is the place causing the error
			}
			for (int j = 0; j < contextDropDowns.size(); j++) {
				IWDNode node =
					wdContext.getChildNode(
						(String) contextDropDowns.elementAt(j) + "Overview",
						0);
				node.setLeadSelection(j);
			}

		}

What should i do to avoid this error?

There is quite similar thread reported, but no solution given in the thread.

javalangindexoutofboundsexception-index-0-size-0

Appreciate any comment/suggestion.

regards,

Prakesh.