How do I find the second index of a character in a string. For instance:
String a="aa{aaaaaaa{aaa}";
I'd like to find the index value of the second {. Here it is 10.
Find the first one, move one right, then find the next one from there. That's the second :)
int secondIndex = a.indexOf('{', a.indexOf('{')+1);
Try to overloaded version of indexOf(), which takes the starting index as 2nd parameter.
str.indexOf("{", str.indexOf("{") + 1);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With