I want to compare two strings for equality when either or both can be null
.
So, I can\'t simply call .equals()
as it can contain null<
Since version 3.5 Apache Commons StringUtils has the following methods:
static int compare(String str1, String str2)
static int compare(String str1, String str2, boolean nullIsLess)
static int compareIgnoreCase(String str1, String str2)
static int compareIgnoreCase(String str1, String str2, boolean nullIsLess)
These provide null safe String comparison.