java string into an array of strings

There are a string of Chinese characters, you want them into an array of strings, each element is a character array.

1.split function

public  static  void main (String [] args) throws SQLException { 
        String str1 = "Adidas adidas neo VS JOG men shoes DB0466EH1696EH1698EH1699" ; 
        String [] S = str1.split ( "" );
         for (each String: S) { 
            the System .out.println (each); 
        } 
    }

2. cycle to achieve

public static void main(String[] args) throws SQLException {
        String str1 = "阿迪达斯adidas neo VS JOG男女休闲鞋DB0466EH1696EH1698EH1699";
         int length = str1.length();
         String[] arr2 = new String[length];
         for(int i=0; i<length; i++) {
             arr2[i] = str1.charAt(i) + "";
             System.out.println(arr2[i]);
         }
         System.out.println(arr2.length);     
    }

operation result:

 

Guess you like

Origin www.cnblogs.com/qilin20/p/12354867.html