public static boolean areStringEquals ( String string1 , String string2 ) { /* string1 string2 outcome * null null true * null x false * x null false * x y false * x x true */ // XXX both null must be unequal? If yes, boolean must be too? if ( string1 == null && string2 == null ) { return false ; } else if ( string1 != null && ! string1 . equals ( string2 ) ) { return false ; } else if ( string2 != null && ! string2 . equals ( string1 ) ) { return false ; } return true ; }
Checks if two strings are equals . The strings can be both null one of them null or none of them null .