package arrays; public class ArrayInsert { public static void main(String args[]) { int[] values = { 3, 6, 10, 12, 100, 200, 250, 500, 0, 0}; // Inserting an element int newElement = 53; int pos = 4; int currentSize = 8; // option 1: if order doesn't matter, just add at the end if (currentSize < values.length) { currentSize++; values[currentSize - 1] = newElement; } // option 2: if order matters shift to makes space at position if (currentSize < values.length) { currentSize++; for (int i = currentSize - 1; i > pos; i--) { values[i] = values[i - 1]; } values[pos] = newElement; } } }