In this example we will show you how to use math.abs(x) to return the absolute (positive) value of x in Java.
Source Code
package com.beginner.examples;
public class Abs {
public static void main(String[] args) {
System.out.println(Math.abs(-3)); // return the absolute (positive) value
}
}
Output:
3