Home >>Java Math Methods >Java Math.nextUp() Method

# Java Math.nextUp() Method

### Java Math.nextUp() Method

The Math.nextUp() in Java Math is an embedded method which is used to returns the floating-point value in the direction of positive infinity, adjacent to the user-specified parameter (d). This method is similar to a method nextAfter(d, Double. POSITIVE INFINITY).

### Syntax

```public static double nextUp(double a)
public static float nextUp(float a)
```

### Parameters

a = This parameter is used to starting floating-point value

### Returns

It is used to returns the adjacent floating-point value closer to positive infinity.

1. If the argument is a -1, then this method returns -1.
2. If the argument is Zero, and we are dealing with double, Double. MIN VALUE will return this method.
3. If the argument is zero, and we are dealing with float, Float. MIN VALUE will return this method.
4. If Positive Infinity is the statement, then this method returns Positive Infinity.

### Java Math.nextUp() Method Example 1

``````
public class MyClass
{
public static void main(String[] args)
{
float a = 0.0f / 0;
System.out.println(Math.nextUp(a));
}
}
```
```
Output:
NaN

### Java Math.nextUp() Method Example 2

``````
public class MyClass
{
public static void main(String[] args)
{
double a = 363.44;
System.out.println(Math.nextUp(a));
}
}
```
```
Output:
363.44000000000005