Determine If Two Strings Are Equal

Determine if two String are equal without having to check for Nulls.

Javadoc available at https://www.javatapas.com/docs/javatapas/string/DetermineIfStringsAreEqual.html


public static boolean determineIfStringsAreEqual(String string1, String string2){

	if (string1 == null && string2 == null){return true;} // yes, we are considering nulls to be equivalent.

	else if (string1 == null && string2 != null){return false;}

	else if (string1 != null && string2 == null){return false;}

	else if (string1.trim().equals(string2.trim())){return true;}

	else {return false;}

}