Friday, August 10, 2012

StringUtils

public static int getLevenshteinDistance(String s, String t):

Find the Levenshtein distance between two Strings.

This is the number of changes needed to change one String into another, where each change is a single character modification (deletion, insertion or substitution).


Example:
StringUtils.getLevenshteinDistance("pramod",StringUtils.reverse("prmaod"))


Output:
4

Q: How to display the Collection elements in customized way, like, one element in a a line?

Solution:
List<String> list = new ArrayList<String>();
list.add("one");
list.add("two");
list.add("three");
      
System.out.println(StringUtils.join(list, '\n'));

Output:
one
two
three