Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created August 7, 2019 15:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parzibyte/6b616fcc383da4ecc2eaa9145ec6ffeb to your computer and use it in GitHub Desktop.
Save parzibyte/6b616fcc383da4ecc2eaa9145ec6ffeb to your computer and use it in GitHub Desktop.
public static int existeEnArreglo(int[] arreglo, int busqueda) {
for (int x = 0; x < arreglo.length; x++) {
if (arreglo[x] == busqueda) {
return x;
}
}
return -1;
}
public static int existeEnArreglo(String[] arreglo, String busqueda) {
for (int x = 0; x < arreglo.length; x++) {
if (arreglo[x].equals(busqueda)) {
return x;
}
}
return -1;
}
public static int existeEnArreglo(float[] arreglo, float busqueda) {
for (int x = 0; x < arreglo.length; x++) {
if (arreglo[x] == busqueda) {
return x;
}
}
return -1;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment