Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created August 7, 2019 16:47
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/3bff7877dcce8ca96ff307a4fe4cc81c to your computer and use it in GitHub Desktop.
Save parzibyte/3bff7877dcce8ca96ff307a4fe4cc81c to your computer and use it in GitHub Desktop.
/*
Probar igualdad de cadenas usando Java
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 == 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