Created
January 22, 2022 07:05
-
-
Save AngryCarrot789/4b909d842802ab1638c7df88a2fb9eef to your computer and use it in GitHub Desktop.
Move array element to the end of an array
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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