Java Char Array Create toCharArrays(String[] a)

Here you can find the source of toCharArrays(String[] a)

Description

Converts a String[] to char[][].

License

Open Source License

Declaration

public static char[][] toCharArrays(String[] a) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright ? 2000, 2013 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:/*w w w. jav a  2  s. c om*/
 * IBM Corporation - initial API and implementation
 *
 *******************************************************************************/

public class Main {
    /**
     * Converts a String[] to char[][].
     */
    public static char[][] toCharArrays(String[] a) {
        int len = a.length;
        char[][] result = new char[len][];
        for (int i = 0; i < len; ++i) {
            result[i] = toChars(a[i]);
        }
        return result;
    }

    /**
     * Converts a String to char[].
     */
    public static char[] toChars(String s) {
        int len = s.length();
        char[] chars = new char[len];
        s.getChars(0, len, chars, 0);
        return chars;
    }
}

Related

  1. toCharArray(String str)
  2. toCharArray(String str)
  3. toCharArray(String string)
  4. toCharArray(String[] v)
  5. toCharArray(StringBuffer stringbuffer)
  6. toClassArray(final Object[] args)
  7. toClassArray(Object[] params)
  8. toClassArray(String[] classNames)
  9. toClasses(ClassLoader classLoader, String[] argClassNames)