In this tutorial, we will see how to create a short array with the help of short buffer.
ShortBuffer API:
The java.nio.ShortBuffer class extends java.nio.Buffer class. It provides the following methods:
| Return type | Method | Description |
| static ShortBuffer | allocate( int capacity) | The allocate(..) method allocate a short buffer of given capacity. |
| short[] | array() | The array() method returns short array based on short buffer. |
| abstract short | get() | The get() method read short value from current position and increment position.. |
import java.nio.*;
|
|
C:\>java ShortBuffArray Capacity of short buffer : 1024 Content in shortbuffer : 43 44 45 Length of short buffer array : 1024 Content in short buffer array : 43 44 45 |
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.