Given the String data, delimited by : and comma separated
String times = 6:10000:first,12:12000:second,18:15000:third
I need to get the third value from the last comma separated list, in this above case 15000
Or 20000 in the below case
String times = 6:10000:first,12:12000:second,18:15000:third,24:20000:fourth
Or 30000 in the below case
String times =
6:10000:first,12:12000:second,18:15000:third,24:20000:fourth,30:30000:fourth
Something like:
public String getLastTimeFromCommaSeparatedList() {
return times.substring(mileages.lastIndexOf(':') + 2);
}
I'm unclear how I can get the value I need, given the comma separated list is of an unknown length.