Skip to content

Instantly share code, notes, and snippets.

@TheFinestArtist
Created July 25, 2015 14:31
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TheFinestArtist/c181d0c1ce0586c412bc to your computer and use it in GitHub Desktop.
Save TheFinestArtist/c181d0c1ce0586c412bc to your computer and use it in GitHub Desktop.
IntArrayHelper.java
/**
* IntArrayHelper
*
* Created by TheFinestArtist
*/
public class IntArrayHelper {
public static boolean contains(int[] array, int value) {
if (array == null)
return false;
for (int i : array)
if (i == value)
return true;
return false;
}
public static int[] add(int[] array, int value) {
if (array == null)
return new int[]{value};
int[] newArray = new int[array.length + 1];
for (int i = 0; i < array.length; i++)
newArray[i] = array[i];
newArray[array.length] = value;
return newArray;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment