Saturday, June 21, 2014

Case Insensitive Check in List



Java does not provide a ignore case comparison of Strings in a List. I have a pretty simple implementation for the same,

public static boolean listContainsIgnoreCase(List listToCheck, String stringToCheck)
{
for (String s : listToCheck) 
{
       if (stringToCheck.equalsIgnoreCase(s)) return true;
   }
return false;
}

Cheers.

No comments :