Yes, you could do: arr[0] = null;and poof, button1 disappeared from the array.
If you want the array to be smaller than, say, 2 arrays of elements, you will need to make a copy of the array using System.arraycopy(originalArray, 1, destinationArray, 0, 2), by copying the last two elements into an array of two elements.
Best solution: just use Flipin 'ArrayList as what it is created for.
Note that aside, your question has nothing to do with Swing.
source
share