String () { StringBuilder b = new StringBuilder(); b.append('{'); for (int i = nextSetBit(0); i >= 0; i = nextSetBit(i + 1)) { int endOfRun = nextClearBit(i); if (endOfRun - i > 1) { if (b.length() != 1) { b.append(", "); } b.append(i).append("...").append(endOfRun-1); i = endOfRun; } else { do { if (b.length() != 1) { b.append(", "); } b.append(i); } while (++i < endOfRun); } } b.append('}'); return b.toString(); }