Java IO Tutorial - Java FloatBuffer.allocate(int capacity)








Syntax

FloatBuffer.allocate(int capacity) has the following syntax.

public static FloatBuffer allocate(int capacity)

Example

In the following code shows how to use FloatBuffer.allocate(int capacity) method.

import java.nio.FloatBuffer;
import java.util.Arrays;
/*w w  w . j  av  a 2s .c o m*/
public class Main {
  public static void main(String[] args) {
    FloatBuffer floatBuffer = FloatBuffer.allocate(10);
    floatBuffer.put(1.23F);
    
    System.out.println(Arrays.toString(floatBuffer.array()));

  }
}

The code above generates the following result.