Buffer class provides ‘capacity’ method that returns the
total number of elements that a buffer can accommodate.
Find the below working application.
package com.sample.nio; import java.nio.Buffer; import java.nio.ByteBuffer; public class Test { public static void main(String args[]) throws Exception { Buffer byteBuffer = ByteBuffer.allocate(10); System.out.println("Capacity of the buffer : " + byteBuffer.capacity()); } }
Output
Capacity of the buffer : 10
No comments:
Post a Comment