Specification for CharBuffer.subSequence(int start, int end) says "new buffer's capacity will be that of this buffer, its position will be position() + start, and its limit will be position() + end."
But in actual new buffer's capacity, limit and position values are different from what spec says.
String source = "This is the string used to test subSequence() method";
CharBuffer c = CharBuffer.wrap(source.toCharArray());
int position = 5;
int start = 5;
int end = 10;
c.position(position);
CharBuffer cNew = (CharBuffer)(c.subSequence(start,end));
int pos = c.position()+start;
int lim = c.position()+end;
System.out.println("position: "+cNew.position()+" Expected: "+pos);
System.out.println("limit: "+cNew.limit()+" Expected: "+lim);
System.out.println("capacity: "+cNew.capacity()+" Expected: "+c.capacity());
results in
position: 0 Expected: 10
limit: 5 Expected: 15
capacity: 5 Expected: 52