Java String to List toList(String str)

Here you can find the source of toList(String str)

Description

Converts a string to a list of Characters.

License

Creative Commons License

Declaration

public static ArrayList<Character> toList(String str) 

Method Source Code

//package com.java2s;
/**/*from www.  j ava2  s  .c om*/
 * Computes the Levenshtein Distance between two strings.
 * <p/>
 * This code is sourced and unmodified from wikibooks under
 * the Creative Commons attribution share-alike 3.0 license and
 * by be re-used under the terms of that license.
 * <p/>
 * http://creativecommons.org/licenses/by-sa/3.0/
 * <p/>
 * TODO: re-implement for efficiency/licensing possibly.
 */

import java.util.ArrayList;

public class Main {
    /**
     * Converts a string to a list of Characters.
     */
    public static ArrayList<Character> toList(String str) {

        ArrayList<Character> myArrayList = new ArrayList<>(str.length());

        for (int i = 0; i < str.length(); i++) {
            myArrayList.add(i, str.charAt(i));
        }

        return myArrayList;
    }
}

Related

  1. toList(String list)
  2. toList(String s)
  3. toList(String s, String delim)
  4. toList(String s, String delimiter)
  5. toList(String str)
  6. toList(String string)
  7. toList(String text)
  8. toList(String transaction)
  9. toList(String val)