Doublons possibles:
Gracefully avoiding NullPointerException in Java
Multilingual fields in DB tablesIf-statement - Vérifie Chaîne contre variable ou variable par rapport à Chaîne?double exact
Qu'aimez-vous plus? Je déteste voir le dernier. Cela semble juste en arrière.
String randomtext = "stack overflow";
if(randomtext.equals("stack overflow"))
{
//do something
}
ou
String randomtext = "stack overflow";
if("stack overflow".equals(randomtext))
{
//do something
}
Dupe de http://stackoverflow.com/questions/963936/gracefully-avoiding-nullpointerexception-in-java –
Si vous savez avec certitude que randomtext est non nul, le premier est plus lisible. –