Java Program to Delete Element at End of Array

delete last array element using java

In this tutorial, we will learn writing Java program to delete a given element of an array from the end and print the array. Our program will delete the element from end (which is specified by the user) of the given array.

For example

Case 1: If the given array is {1, 2, 3, 4}.

            Then output should be {1, 2, 3}.

Case 2: If the given array is {9, 2, 4, 8.

            Then output should be {9, 2, 4}.

Java Program to Delete Element at End of Array

Output

Java Program Delete Element End Array

Explanation

For the input array {1, 2, 3, 4, 5}. The user inputs element 5 to remove from the list and print return the array elements except the last element of the array.