string To Character Array - Java java.lang

Java examples for java.lang:String Array

Description

string To Character Array

Demo Code


//package com.java2s;

public class Main {
    public static void main(String[] argv) throws Exception {
        String s = "java2s.com";
        System.out.println(java.util.Arrays
                .toString(stringToCharacterArray(s)));
    }//  w w  w .  j  a v  a 2  s  . c  om

    private static Character[] stringToCharacterArray(String s) {
        char[] arr = s.toCharArray();
        Character[] carr = new Character[arr.length];
        for (int i = 0; i < arr.length; i++) {
            carr[i] = arr[i];
        }

        return carr;
    }
}

Related Tutorials