This error occures when array or collection size is lessear then expected.
E.g. when you say String[] values = otherElement.getValues();
You are expecting values size to be 10 and so you try to access values[9] but actual values size is < 10. So no way you have values[9] in place. In that case you will face above error.
Best way to resolve that is by placing if condition before accessing the value.
String singleValue;
String[] values = otherElement.getValues();
if(values.length >= 10)
singleValue = values[9];
Hope that helps.