Here is an example String, which contains 2 delimiters used for parsing the String to integers:
"1,25,3-6,14,16-19"
The integers in the aforementioned string have to be parsed and added to ArrayList cotaining integers. So the ArrayList has to contain:
1,3,4,5,6,14,16,17,18,19,25
The values in the original string are never mentioned twice. So, there are no crossing sections. Below you can see the incomplete code I wrote so far, but I think that I'm going in a completely wrong direction and there should be an easier way to solve the parsing.
List<Integer> temp = new ArrayList<>();
Scanner s = new Scanner(System.in);
String str = s.nextLine();
char[] strCh = str.toCharArray();
for (int j = 0; j < strCh.length; j++) {
char c = strCh[j];
String number = "";
char operator = 'n';
if (Character.isDigit(c)) {
do {
number += c;
j++;
if (j != strCh.length - 1)
c = strCh[j];
} while (j < strCh.length && Character.isDigit(c));
} else if (c == ',') {
operator = ',';
temp.add(Integer.parseInt(number));
number = "";
} else if (c == '-') {
//still not sure
}
}