As mentioned above, the addition of array elements is performed through functions, and the deletion of arrays is also performed through this function.
For example, the code is as follows:
1 // Import the package required for input 2 import java.util.Scanner; 3 4 public class test6 5 { 6 public static void main(String [] arys) 7 { 8 int [] arr1 = {1,2,3, 4,5 }; 9 10 Scanner sc = new Scanner(System.in); // Create an input stream object 11 System.out.println("Please enter the location to delete: " ); 12 int index = sc.nextInt (); // Get the integer value entered by the user 13 14 15 System.arrycopy(arr1,index+1,arr1,index,arry.length-index-1); 16 17 arr1[arr1.length-1] = 0; 18 19 for(int n : arr1) 20 { 21 System.out.print(n+"\t"); 22 } 23 } 24 }