convert string to arraylist in java

前端 未结 7 980
别跟我提以往
别跟我提以往 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:49

    You need to add it like this.

    String str = "abcd...";
    ArrayList chars = new ArrayList();
    for (char c : str.toCharArray()) {
      chars.add(c);
    }
    

提交回复
热议问题