Be concise.
Be useful.
All contributions dictatorially edited by webmasters to match personal tastes.
Please do not paste any copyright violating material.
Please try to avoid dependencies to third-party libraries and frameworks.
List<int[]> a = new ArrayList<>();
int i, x, y, n = s.length(), c;
for (i = y = 0; i < n; ++i)
if (s.charAt(i) == '{') {
x = i + ++y;
while (x < n) {
c = s.charAt(x++);
if (c == '{') ++y;
else if (c == '}')
if (--y == 0) break;
}
a.add(new int[] { i, x - 1 });
}