code: public static IntBuffer allocate (int capacity) {
          if (capacity < 0) {
              throw new IllegalArgumentException();
          }
          ByteBuffer bb = ByteBuffer.allocateDirect(capacity * 4);
          bb.order(ByteOrder.nativeOrder());
          return bb.asIntBuffer();
      }
docs: Creates an int buffer based on a newly allocated int array.
  
  @param capacity the capacity of the new buffer.
  @return the created int buffer.
  @throws IllegalArgumentException if {@code capacity} is less than zero.