import java.nio.*; import java.nio.ByteBuffer; import java.nio.IntBuffer; public class AsInt { public static void main(String[] args) { ByteBuffer byteBuf = ByteBuffer.allocate(1024); System.out.print("\nInformation related to byte buffer :"); System.out.printf("\nByteBuffer Limit = %4d", byteBuf.limit()); System.out.printf("\nByteBuffer position = %2d ", byteBuf.position()); System.out.printf("\nByteBuffer capacity = %4d%n", byteBuf.capacity()); IntBuffer intBuf = byteBuf.asIntBuffer(); System.out.print("Information related to Int buffer :"); System.out.printf("\nIntBuffer Limit = %4d", intBuf.limit()); System.out.printf("\nIntBuffer position = %2d ", intBuf.position()); System.out.printf("\nIntBuffer capacity = %4d%n", intBuf.capacity()); } }