Java Random.nextFloat()

Syntax

Random.nextFloat() has the following syntax.

public float nextFloat()

Example

In the following code shows how to use Random.nextFloat() method.


//  w  w  w  .  ja  v a  2s.  co  m
import java.util.Random;

public class Main {
   public static void main( String args[] ){

      Random randomno = new Random();
 
      // check next float value  
      System.out.println("Next float value: " + randomno.nextFloat());
   }      
}

The code above generates the following result.