Java FloatBuffer Create createFloatBuffer(int numFloats)

Here you can find the source of createFloatBuffer(int numFloats)

Description

Return a FloatBuffer which can hold the specified number of floats.

License

Open Source License

Parameter

Parameter Description
numFloats The number of floats this FloatBuffer should hold.

Return

A float buffer which can hold the specified number of floats.

Declaration

public static FloatBuffer createFloatBuffer(int numFloats) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.FloatBuffer;

public class Main {
    /**//  w  ww  .j  a  va  2  s .co  m
     * Return a FloatBuffer which can hold the specified number of floats.
     *
     * @param   numFloats   The number of floats this FloatBuffer should hold.
     * @return            A float buffer which can hold the specified number of floats.
     */
    public static FloatBuffer createFloatBuffer(int numFloats) {
        return ByteBuffer.allocateDirect(numFloats * Float.BYTES).order(ByteOrder.nativeOrder()).asFloatBuffer();
    }
}

Related

  1. createFloatBuffer(float[] array)
  2. createFloatBuffer(FloatBuffer buffer)
  3. createFloatBuffer(int limit)
  4. createFloatBuffer(int size)
  5. createFloatBufferOnHeap(final int size)
  6. newFloatBuffer(final int theSize)
  7. newFloatBuffer(int len)