Reverse a string, words or sentences
import org.apache.commons.lang.StringUtils;
public class Main {
public static void main(String[] args) {
String words = "The quick brown fox jumps over the lazy dog";
String reversed = StringUtils.reverse(words);
String delimitedReverse = StringUtils.reverseDelimited(words, ' ');
System.out.println("Original: " + words);
System.out.println("Reversed: " + reversed);
System.out.println("Delimited Reverse: " + delimitedReverse);
}
}
Related examples in the same category