Last active
April 4, 2019 14:42
-
-
Save erkanzileli/411736d41c7125b80b38a089741e8f1a to your computer and use it in GitHub Desktop.
Delete an element from an array
This file contains 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 Object[] delete(Object[] array, int index) { | |
Object[] newArray = new Object[array.length - 1]; | |
for (int i = 0; i < array.length; i++) { | |
if (i == index) | |
continue; | |
newArray[i] = array[i]; | |
} | |
return newArray; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment