I am trying to write a method that receives an array of numbers. If there are any zeros in the array it will add another zero, but the array must remain the same length so the last number is deleted from the new array. Here is what I have started to do, but I don't think it is going anywhere.
public static int[] MoveToRightOne(int userArray[] )
{
int newArray [] = new int[userArray.length + 1];
int zero = 0;
for(int i = 0; i < userArray.length; i++)
{
if (userArray[i] == 0)
zero = zero + 1;
newArray[i + zero] = userArray[i - 1];
}
return(userArray);
}