java - ArrayIndexOutOfBoundsException when inserting into an array -


i'm writing program @ point needs put 2 arrays of different lengths 2 dimensional array.

does know why i'm getting arrayindexoutofboundsexception @ specified line?

string[][] proteinarray;  if(proteinsmomfinal.length > proteinsdadfinal.length) {     proteinarray = new string[proteinsmomfinal.length][2]; } else {     proteinarray = new string[proteinsdadfinal.length][2]; }  for(int = 0; < proteinsmom.length; i++) {     proteinarray[i][0] = proteinsmomfinal[i];          // error here }  for(int = 0; < proteinsdad.length; i++) {     proteinarray[i][1] = proteinsdadfinal[i]; } 

you should using proteinsmomfinal in statement. how can know proteinsmom same length proteinsmomfinal?

for(int = 0; < proteinsmomfinal.length; i++) {     proteinarray[i][0] = proteinsmomfinal[i];          // error here } 

Comments