Java IntBuffer compare capacity against ByteBuffer after converting from ByteBuffer

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());


   }/*from ww w.  j a  v a2s  .com*/
}



PreviousNext

Related