How to convert a String array to char array in Java

前端 未结 6 1695
孤城傲影
孤城傲影 2020-12-10 00:33

We are given an array of Strings and what we require is a char[], i.e, array of all characters in all the Strings For example:

Input: [i, love, you]

output:

6条回答
  •  粉色の甜心
    2020-12-10 00:42

    public static void main(String[] args)
    {
        String sentence="Gokul Krishna is class leader";
        String[] array=sentence.split("\\s");
        int counter;
        //String word = new String();
        for(String word:array)
        {
            counter=0;
            char[] wordArray=word.toCharArray();
            for(int i=0;i

提交回复
热议问题