Search code examples
javacharniobytebuffer

What is the difference between ByteBuffer and CharBuffer in Java NIO?


What is difference between ByteBuffer and CharBuffer in case java.nio package. Is it the same difference as byte and char has?


Solution

  • You can see it like that. A ByteBuffer is a buffer for (8-bit) byte values while a CharBuffer holds (16-bit) chars.