1

Say I have string A = "AAaabb";

How do I split this string when there are no spaces, so I can't use space as a delimiter. Is there a like null delimiter, where it just splits all characters?

basically I want an array with each individual character [A, A, a, a, b, b]

HappyCoder
  • 21
  • 3

3 Answers3

1

Try this!

Use A.split(""); //A is your array

String A = "AAaabb";
String Array[] = A.split("");
System.out.println(Array[0]); // print A
Kusal Kithmal
  • 1,255
  • 1
  • 10
  • 25
1

just do this :

    String input =  "AAaabb";
    char[] output;
    output = input.toCharArray();
kevin ternet
  • 4,514
  • 2
  • 19
  • 27
0
public static void main(String[] args) {
    String s = "AAaabb";
    String[] array = s.split("");

    for (String string : array) {
        System.out.println(string);
    }
}

result: A A a a b b

Wai Ha Lee
  • 8,598
  • 83
  • 57
  • 92
dinodrits
  • 24
  • 4