class Merge{
public static void main(String[] args){
int[]A = {1,2,};
int[]B = {7,8,9};
int[]C = new int[A.length + B.length];
int aIndex = 0;
int aCount = A.length;
int cIndex = C.length;
while (aIndex < aCount){
if(A[aIndex] < B[aIndex]){
C[aIndex]= A[aIndex];
}
aIndex++;
}//end while
for(int bIndex = 1; bIndex < cIndex ; bIndex++){
C[bIndex] = B[bIndex];//Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 3
//at Merge.main(Merge.java:23)
}
for (int i = 0; i < C.length; i++){
System.out.println(C);
}
}//end main
}//end class
I am trying to merge the two arrays above but I am getting an out of bounds error? where am I going wrong?