convert string to arraylist in java

前端 未结 7 974
别跟我提以往
别跟我提以往 2020-12-10 01:03

How to convert a String without separator to an ArrayList.

My String is like this:

String str = \"abcd...\"
         


        
7条回答
  •  鱼传尺愫
    2020-12-10 01:32

    String myString = "xxx";
    ArrayList myArrayList = myString.chars().mapToObj(x -> (char) x).collect(toCollection(ArrayList::new));
    myArrayList.forEach(System.out::println);
    

提交回复
热议问题