Created
September 2, 2019 18:00
-
-
Save parzibyte/7ad651ca4172c48a5b77c74cc055828e to your computer and use it in GitHub Desktop.
This file contains 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
// Voy a buscar únicamente comparando el código | |
boolean encontrado = false; | |
for (int x = 0; x < productos.size(); x++) { | |
Producto p = productos.get(x); | |
if (p.getCodigo().equals(busqueda.getCodigo())) { | |
encontrado = true; | |
break; // Terminar ciclo, pues ya lo encontramos | |
} | |
} | |
// Al terminar el ciclo comprobamos si se movió la variable | |
if (encontrado) { | |
System.out.println("El producto existe"); | |
} else { | |
System.out.println("El producto NO existe"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment