Preview:
 public static void main(String[] args) {
        System.out.println("Try programiz.pro");
      int[] arr = {1,2,3,4,5};
      
      int indexToRemove = 2;
      
      int[] newArray = new int[arr.length-1];
      
      System.arraycopy(arr,0, newArray, 0,indexToRemove );
        System.arraycopy(arr,indexToRemove+1, newArray,indexToRemove,  arr.length - indexToRemove -1);
        
         System.out.println(Arrays.toString(newArray));
    }
---------------
    ArrayList<Integer> arr = new ArrayList<Integer>();
     arr.add(1);
      arr.add(2);
       arr.add(3);
        arr.add(4);
         arr.add(5);
         
         int indexToRemove = 3;
         
          arr.remove(elementToRemove);
          
          for(int num : arr){
              System.out.println(" "+ num);
          }
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter