CharBuffer buffer = CharBuffer.allocate (8); buffer.position (3).limit (5); CharBuffer sliceBuffer = buffer.slice(); println (buffer); println (sliceBuffer); char [] myBuffer = new char [100]; CharBuffer cb = CharBuffer.wrap (myBuffer); cb.position(12).limit(21); CharBuffer sliced = cb.slice(); println (cb); println (sliced);
System.out.println ("pos=" + cb.position() + ", limit=" + cb.limit() + ", capacity=" + cb.capacity() + ", arrayOffset=" + cb.arrayOffset());