What is ByteBuffer?
In this article, the editor introduces "what is ByteBuffer" in detail, the content is detailed, the steps are clear, and the details are handled properly. I hope this "what is ByteBuffer" article can help you solve your doubts.
Introduction
ByteBuffer is not only a data structure that must be mastered in nio/aio programming, but also the basic knowledge that must be learned to master tio.
Suppose you don't know Map, List or Set, then you will accomplish nothing in the field of programming. By the same token, if you don't understand ByteBuffer, you can't get a foothold in nio/aio programming.
First acquaintance of ByteBuffer
We can think of bytebuffer as a data structure composed of the following attributes
Byte [] bytes: used to store data
Int capacity: used to represent the capacity of bytes, then you can imagine that capacity is equal to bytes.size (), which is immutable after initializing bytes.
Int limit: used to indicate how much data is actually installed in bytes. You can easily imagine limit.