Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Last active August 7, 2019 15:31
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/e24fd98db3ddd9e2653ffba94975d09a to your computer and use it in GitHub Desktop.
Save parzibyte/e24fd98db3ddd9e2653ffba94975d09a to your computer and use it in GitHub Desktop.
public static void main(String[] args) {
// Demostración con enteros
int[] numeros = { 50, 21, 6, 97, 18 };
int numeroBuscado = 20;
int posicionDeElementoBuscado = existeEnArreglo(numeros, numeroBuscado);
if (posicionDeElementoBuscado == -1) {
System.out.println("El elemento NO existe en el arreglo");
} else {
System.out.println("El elemento existe en la posición: " + posicionDeElementoBuscado);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment