Skip to content

Instantly share code, notes, and snippets.

@AngryCarrot789
Created January 22, 2022 07:05
Show Gist options
  • Save AngryCarrot789/4b909d842802ab1638c7df88a2fb9eef to your computer and use it in GitHub Desktop.
Save AngryCarrot789/4b909d842802ab1638c7df88a2fb9eef to your computer and use it in GitHub Desktop.
Move array element to the end of an array
public static <T> void moveElementToEnd(T[] array, int index) {
T element = array[index];
System.arraycopy(array, index + 1, array, index, array.length - index - 1);
array[array.length - 1] = element;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment