Does Array contain a certain item
class Main {
final public static boolean contains(final int[] a, final int candidate) {
return contains(a, a.length, candidate);
}
final private static boolean contains(final int[] a, final int numItems,
final int candidate) {
for (int i = 0; i < numItems; i++) {
if (candidate == a[i])
return true;
}
return false;
}
}
Related examples in the same category