exception - Why am I getting a java.nio.BufferOverflowException -


i tried create simple program fun, i'm getting bufferoverflowexception:

bytebuffer bytebuffer = bytebuffer.allocatedirect(10); floatbuffer floatbuffer = bytebuffer.asfloatbuffer(); floatbuffer.put(new float[] {1, 0, 0}); 

what wrong?

when use bytebuffer.allocatedirect(10); ask allocating 10 bytes of memory. putting 3 float in buffer. each float uses 4 bytes of memory per official documentation. using 12 bytes , overflow.

to solve problem use 12 bytes instead of 10.


Comments

Popular posts from this blog

php - Permission denied. Laravel linux server -

google bigquery - Delta between query execution time and Java query call to finish -

python - Pandas two dataframes multiplication? -