In this tutorial, we will discuss how to clean a short buffer by using clear method.
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. |
| abstract ShortBuffer | put(short s) | The put(..)method write a given short value at current position. |
Buffer API:
The java.nio.Buffer class extends java.lang.Object class. It provides the following methods:
| Return type | Method | Description |
| final Buffer | clear() | The clear() method clear the buffer. |
| Int | remaining() | The remaining() method returns remaining element in buffer. |
import java.nio.*;
|
| C:\>java ClearShortBuff Short data in a short buffer. 2354 666 6677 Number of remaining elements in short buffer : 0 Clear. |
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.