Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created August 7, 2019 16:48
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/3a5717eb98cdfde4e2bc3e74fee20315 to your computer and use it in GitHub Desktop.
Save parzibyte/3a5717eb98cdfde4e2bc3e74fee20315 to your computer and use it in GitHub Desktop.
/*
Probar igualdad de cadenas usando Java (forma correcta)
parzibyte.me/blog
*/
class Main {
public static void main(String[] args) {
// Dos cadenas que tienen el mismo contenido.
// Deberían ser iguales, ¿verdad?
String unaCadena = new String("Hola");
String otraCadena = new String("Hola");
// Vamos a comprobarlo:
if(unaCadena.equals(otraCadena)){
System.out.println("Las cadenas son iguales :-)");
}else{
System.out.println("Las cadenas no son iguales :(");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment