I need a little help. I'm trying to put together a small Java program that creates and returns an array containing all elements of a, each of these duplicated. However, every time I try to execute my code I get an "out of bounds" exception. Please give me an idea of where I'm going wrong. Thanks! Here is what I have so far:
public class integerStutter
{
public static int[] stutter(int [] a){
int[] j = new int[a.length*2];
for(int i=0; i < j.length; i++){
j[i] = a[i];
j[i+1] = a[i];
i++;
}
return j;
}
}