Why does ByteBuffer\'s flip() method called \"flip\"? What is \"flipped\" here? According to apidoc, two successive flips won\'t restore original state, and multiple flips w
ByteBuffer is ill designed. There are lots of complaints from decent programmers.
So don't try to reason about it, just study and use the API carefully.
Now I cannot badmouth it without presenting an alternative, so here it is:
A buffer has a fixed capacity
; it maintains 2 pointers: start
and end
. get()
returns the byte at the start
position and increments start
. put()
puts the byte at the end
position and increments end
. No flip()
!