Skip to content

Instantly share code, notes, and snippets.

@dan-dm
Last active May 16, 2020 14:28
Show Gist options
  • Save dan-dm/72e500688d2a6442685b2a635be42e6a to your computer and use it in GitHub Desktop.
Save dan-dm/72e500688d2a6442685b2a635be42e6a to your computer and use it in GitHub Desktop.
Created with Copy to Gist
public static int[] addOneIntToArray(int[] initialArray , int newValue) {
int[] newArray = new int[initialArray.length + 1];
for (int index = 0; index < initialArray.length; index++) {
newArray[index] = initialArray[index];
}
newArray[newArray.length - 1] = newValue;
return newArray;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment