Java Char Array Create toCharArray(String str)

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

Description

Get the character array for a string.

License

Open Source License

Parameter

Parameter Description
str a string

Return

the char array

Declaration

public static char[] toCharArray(String str) 

Method Source Code

//package com.java2s;
/*//from   ww  w.j  av a2s  . co  m
 * Helma License Notice
 *
 * The contents of this file are subject to the Helma License
 * Version 2.0 (the "License"). You may not use this file except in
 * compliance with the License. A copy of the License is available at
 * http://adele.helma.org/download/helma/license.txt
 *
 * Copyright 1998-2003 Helma Software. All Rights Reserved.
 *
 * $RCSfile$
 * $Author$
 * $Revision$
 * $Date$
 */

public class Main {
    /**
     * Get the character array for a string. Useful for use from
     * Rhino, where the Java String methods are not readily available
     * without constructing a new String instance.
     * @param str a string
     * @return the char array
     */
    public static char[] toCharArray(String str) {
        return str == null ? new char[0] : str.toCharArray();
    }
}

Related

  1. toCharArray(String s)
  2. toCharArray(String s)
  3. toCharArray(String s)
  4. toCharArray(String str)
  5. toCharArray(String str)
  6. toCharArray(String string)
  7. toCharArray(String[] v)
  8. toCharArray(StringBuffer stringbuffer)
  9. toCharArrays(String[] a)