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,183
  • 1
  • 9
  • 25
1

just do this :

    String input =  "AAaabb";
    char[] output;
    output = input.toCharArray();
kevin ternet
  • 4,216
  • 2
  • 16
  • 25
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,173
  • 68
  • 59
  • 86
dinodrits
  • 24
  • 4