Mega Code Archive

 
Categories / Java Tutorial / Internationalization
 

Iterate over the characters in the backward direction

import java.text.CharacterIterator; import java.text.StringCharacterIterator; public class Main {   public static void main(String[] argv) throws Exception {     CharacterIterator it = new StringCharacterIterator("abcd");     for (char ch = it.last(); ch != CharacterIterator.DONE; ch = it.previous()) {       System.out.println(ch);     }   } }