Java ByteBuffer compare capacity against IntBuffer after converting to IntBuffer

Introduction

IntBuffer uses four bytes to store an int.

import java.nio.ByteBuffer;
import java.nio.IntBuffer;

public class Main {
   private static final int BSIZE = 16;

   public static void main(String[] args) {
      ByteBuffer bb = ByteBuffer.allocate(BSIZE);

      System.out.println(bb.capacity());
      IntBuffer ib = bb.asIntBuffer();
      System.out.println(ib.capacity());


   }/* w ww . j a v  a2 s  . c  o m*/
}



PreviousNext

Related