Java Data Type Tutorial - Java Math.nextUp(float f)








Syntax

Math.nextUp(float f) has the following syntax.

public static float nextUp(float f)

Example

In the following code shows how to use Math.nextUp(float f) method.

/* ww w  .  j av a2  s.c  o m*/
public class Main {

   public static void main(String[] args) {

      float x = 12345.123f;
      float y = 123.123456f;

      // print the next floating numbers towards positive infinity
      System.out.println("Math.nextUp(" + x + ")=" + Math.nextUp(x));
      System.out.println("Math.nextUp(" + y + ")=" + Math.nextUp(y));

   }
}

The code above generates the following result.