List of usage examples for java.text StringCharacterIterator last
public char last()
From source file:Util.java
/** * Returns a string that contains all characters of the given string in * reverse order.//w ww . ja va2 s .c o m * * @param str * * @return */ public String reverse(String str) { if (str == null) { return null; } char[] newStr = new char[str.length()]; StringCharacterIterator iterator = new StringCharacterIterator(str); int i = 0; for (char ch = iterator.last(); ch != CharacterIterator.DONE; ch = iterator.previous()) { newStr[i] = ch; i++; } return new String(newStr); }