1. split 函数

  • 通过空字符串作为分隔符
String str = "字符串ABC123";
		String[] s = str.split("");
		for(String each : s) {
			System.out.println(each);
		}
	// ["字", "符", "串", "A", "B", "C", "1", "2", "3"]
  • 通过符号作为分隔符
String str1 = "字,符串,ABC,123";
		String[] s1 = str1.split(",");
		for(String each : s1) {
			System.out.println(each);
		}
	// ["字", "符串", "ABC", "123"]

2. 循环实现

String str = "字符串ABC123";
        int length = str.length();
        String[] arr = new String[length];
        for(int i=0; i<length; i++) {
            arr[i] = str.charAt(i) + "";
            System.out.println(arr[i]);
        } 
      // ["字", "符", "串", "A", "B", "C", "1", "2", "3"]