I want to split lines of words on the letter A. For example: AoAoAoA should result in [o, o, o], which it does with my code. But the problem is where the word has no characters between two A's, such as: AoAA that will only result in [o]. How can I adjust my code in order for the result to be [o,] instead?
This is because I want to see if there are equal amount of the same characters between the delimiter. And if there are, something will happen, and if not something else will happen. "AoAA" does not have equal amounts of "o" between the A's and should therefore be treated as such.
List<String> myList = new ArrayList <>();
String row = scanner.nextLine();
String [] splitString = row.split ("A");
for (String s : splitString) {
if (!s.equals(splitString[0])) {
myList.add(s);
}}
ps. I understand that my questions seems to be a duplicate, I have tried several of the solutions that are similar to my problem, but for some reason they do not solve my issue. For example, by simply adding split (string, int), has not solved anything for me.