Created
July 25, 2015 14:31
-
-
Save TheFinestArtist/c181d0c1ce0586c412bc to your computer and use it in GitHub Desktop.
IntArrayHelper.java
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
/** | |
* 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