Skip to content

Instantly share code, notes, and snippets.

@TwiN
Created June 11, 2016 23:24
Show Gist options
  • Save TwiN/f7c93f21ac926b58620d4a153f4355fa to your computer and use it in GitHub Desktop.
Save TwiN/f7c93f21ac926b58620d4a153f4355fa to your computer and use it in GitHub Desktop.
public static boolean isInList(String[] myList, String element) {
for(String s: myList) {
if (s.equals(element)) { return true; }
}
return false;
}
public static boolean isInList(char[] myList, char element) {
for(char c: myList) {
if (c == element) { return true; }
}
return false;
}
public static boolean isInList(int[] myList, int element) {
for(int i: myList) {
if (i == element) { return true; }
}
return false;
}
public static boolean isInList(float[] myList, float element) {
for(float i: myList) {
if (i == element) { return true; }
}
return false;
}
public static boolean isInList(double[] myList, double element) {
for(double i: myList) {
if (i == element) { return true; }
}
return false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment