Java Reflection - Java Array.setFloat(Object array, int index, float f)








Syntax

Array.setFloat(Object array, int index, float f) has the following syntax.

public static void setFloat(Object array,  int index,  float f)   throws IllegalArgumentException ,    ArrayIndexOutOfBoundsException

Example

In the following code shows how to use Array.setFloat(Object array, int index, float f) method.

/*  w ww.  j  a v  a  2s.c  o m*/
import java.lang.reflect.Array;
import java.util.Arrays;

public class Main {
  public static void main (String args[]) {
    float[] array = new float[]{1,2,3};
    
    Array.setFloat(array, 1, (float)1);
    
    System.out.println(Arrays.toString(array));


  }
}

The code above generates the following result.