UNB/ CS/ David Bremner/ teaching/ java/ RemoveAt.java
public class RemoveAt{

  public static int[] removeElementAt(int []arr, int i){

    if ( i<0 || i >= arr.length)
      return arr;

    int [] retArr=new int[arr.length-1];

    for (int j=0; j< i; j++){
      retArr[j]=arr[j];
    }
      

    for (int j=i+1; j< arr.length; j++){
      retArr[j-1]=arr[j];
    }

    return retArr;
  }

  

  public static void main(String[] args){

    int[] test={1,2,3,4};

    test=removeElementAt(test,103);

    test=removeElementAt(test,2);

    for (int i=0; i<test.length; i++)
      System.out.println(test[i]);
  }
      
}
/*
cd /home/bremner/teach/1083/misc/
java -Djava.compiler=NONE RemoveAt

1
2
4

Process RemoveAt finished
*/