public class Main {
    private static class TestBuffer {
        private int _length;
        private char[] _buffer;

        protected TestBuffer(String s) {
            _buffer = s.toCharArray();
            _length = _buffer.length;
        }

        public String toString() {
            return new String(_buffer, 0, _length);
        }

        public TestBuffer deleteCharAt(int index) {
            if (index < 0 || _length < index)
                throw new StringIndexOutOfBoundsException();

            if (index == _length)
                return this;

            int tail = _length - index - 1;
            char []buffer = _buffer;

            System.err.println("_length=" + _length + ", index=" + index + ", tail=" + tail);
            for (int i = 0; i < tail; i++)
                buffer[index + i] = buffer[index + i + 1];

            _length--;

            return this;
        }
    }

    public static void main(String[] args) {
        StringBuilder sb = new StringBuilder(64);
        for (int i = 0; i < 64; i++) {
            sb.append(i % 10);
        }
        TestBuffer tb = new TestBuffer(sb.toString());
        System.err.println("  initial: " + tb);
        tb.deleteCharAt(64);
        tb.deleteCharAt(63);
        System.err.println("after(63): " + tb);
        tb.deleteCharAt(5);
        System.err.println(" after(5): " + tb);
    }
}
