Java Data Type Tutorial - Java Math.nextAfter(float start, double direction)








Syntax

Math.nextAfter(float start, double direction) has the following syntax.

public static float nextAfter(float start,  double direction)

Example

In the following code shows how to use Math.nextAfter(float start, double direction) method.

/* w ww . ja v a2  s.com*/
public class Main {

   public static void main(String[] args) {

      float x = 12345.123f;
      double y = 123.12345;

      // print the next number for x towards y
      System.out.println("Math.nextAfter(" + x + "," + y + ")="
              + Math.nextAfter(x, y));

   }
}

The code above generates the following result.