convert string to arraylist in java

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

    you can do it like this:

    import java.util.ArrayList;
    
    public class YourClass{
    
        public static void main(String [] args){
    
            ArrayList char = new ArrayList();
            String str = "abcd...";
    
            for (int x = 0; x < str.length(); x ++){
                char.add(str.charAt(x));
            }
        }
    }
    

提交回复
热议问题