Split a string into its individual characters (also as Strings). - Java java.lang

Java examples for java.lang:String Split

Description

Split a string into its individual characters (also as Strings).

Demo Code


//package com.java2s;
import java.util.ArrayList;

import java.util.List;

public class Main {
    /**/*from www  .  ja  va  2s  .co  m*/
     * Split a string into its individual characters (also as Strings).
     */
    public static List<String> charSplit(String str) {
        List<String> rtn = new ArrayList<String>(str.length());
        for (int i = 0; i < str.length(); i++) {
            rtn.add("" + str.charAt(i));
        }

        return rtn;
    }
}

Related Tutorials