I cannot understand particular details of CharBuffer
equals()
method functioning.
I don't understand this "considered independently of their starting positions" phrase:
Two char buffers are equal if, and only if,
They have the same element type,
They have the same number of remaining elements, and
The two sequences of remaining elements, considered independently of their starting positions, are pointwise equal.
I studies these good examples - more examples, but I don't understand the idea.
Could anyone explain in different words and with minimal insightful example code?
Particularly I find this strange:
CharBuffer cb1 = CharBuffer.allocate(10);
cb1.put('a');
cb1.put('b');
//cb1.rewind();
System.out.println(cb1);
CharBuffer cb2 = CharBuffer.allocate(10);
cb2.put(4,'a');
cb2.put(5,'b');
//cb2.rewind();
System.out.println(cb2);
// false, uncommenting rewind() - also false
// but shall be true - "considered independently of starting positions" ?
System.out.println(cb1.equals(cb2));