Java FloatBuffer.wrap(float[] array)

Syntax

FloatBuffer.wrap(float[] array) has the following syntax.

public static FloatBuffer wrap(float[] array)

Example

In the following code shows how to use FloatBuffer.wrap(float[] array) method.


import java.nio.FloatBuffer;
import java.util.Arrays;
// w  w  w .  j  a  va  2 s  .co m
public class Main {
  public static void main(String[] args) {
    FloatBuffer floatBuffer = FloatBuffer.wrap(new float[]{1.23F});
    
    floatBuffer.rewind();
    
    System.out.println(Arrays.toString(floatBuffer.array()));

  }
}

The code above generates the following result.





















Home »
  Java Tutorial »
    java.nio »




Buffer
ByteBuffer
ByteOrder
CharBuffer
DoubleBuffer
FloatBuffer
IntBuffer
LongBuffer
MappedByteBuffer
ShortBuffer