Splitting words into letters in Java

Viewed 207388

How can you split a word to its constituent letters?

Example of code which is not working

 class Test {
         public static void main( String[] args) {
             String[] result = "Stack Me 123 Heppa1 oeu".split("\\a");                                                                                   

             // output should be
             // S
             // t
             // a
             // c
             // k
             // M
             // e
             // H
             // e
             // ...
             for ( int x=0; x<result.length; x++) {
                 System.out.println(result[x] + "\n");
             }
         }
     }

The problem seems to be in the character \\a. It should be a [A-Za-z].

7 Answers
Related