import java.io.IOException;
import java.nio.*;

public class CB {
    public static void main(String[] args) throws IOException {
        char[] c = new char[128];
        for (int i = 0; i < 128; i++)
            c[i] = (char)('a' + i);

        final int pos = 8;
        CharBuffer cb = CharBuffer.wrap(c);
        cb.position(pos);
        for (int i = 8; i < 16; i++) {
            char x = cb.charAt(i);
            if (x != c[pos + i])
                throw new RuntimeException(x + " != " + c[16 + 1]);
        }

        cb.position(pos);
        CharSequence cs = cb.subSequence(8, 16);
        for (int i = 0; i < 8; i++) {
            char x = cs.charAt(i);
            if (x != c[pos + 8 + i])
                throw new RuntimeException(x + " != " + c[pos + 8 + i]);
        }

        cb.position(pos);
        char[] dst = new char[8];
        cb.getChars(8, 16, dst, 0);
        for (int i = 0; i < 8; i++) {
            char x = dst[i];
            if (x != c[pos + 8 + i])
                throw new RuntimeException(x + " != " + c[pos + 8 + i]);
        }
    }
}
