Add the following method to the ArrayIntList class from this chapter.
Write a method called stutter that replaces every value with two of that value. For example, if the list initially stores [42, 7, 0, –3, 15] , after the call it should store [42, 42, 7, 7, 0, 0, –3, –3, 15, 15] .
public void stutter()
{
if(size * 2 > elementData.length)
return;
for(int i = 0; i < size; i += 2)
{
int value = elementData[i];
for(int j = size; j >= i + 1; j--)
{
elementData[j] = elementData[j - 1];
}
elementData[i + 1] = value;
size++;
}
}