package arrays; public class ArrayRemove { public static void main(String args[]) { int[] values = { 3, 6, 10, 12, 100, 200, 250, 500 }; //removing an array element int pos = 3; // remove 3rd element int currentSize = 8; // this may not be length if the array is not full //option 1: just move last element to the place of removed element // values[pos] = values[currentSize - 1]; // currentSize--; // option 2: if need to maintain order then you must shift // for (int i = pos + 1; i < currentSize; i++) { // values[i - 1] = values[i]; // } // currentSize--; //note that values.length is still the same //Best to then follow up with: //values[currentSize - 1]= null; } }