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.


//from w w w . j a  v a  2 s  .  co  m
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.





















Home »
  Java Tutorial »
    java.lang »




Boolean
Byte
Character
Class
Double
Enum
Float
Integer
Long
Math
Number
Object
Package
Process
ProcessBuilder
Runnable
Runtime
SecurityManager
Short
StackTraceElement
StrictMath
String
StringBuffer
StringBuilder
System
Thread
ThreadGroup
ThreadLocal
Throwable