int num = -10; int result = Math.abs(num); System.out.println(result); // Output: 10
double num = -9.8; double result = Math.abs(num); System.out.println(result); // Output: 9.8In this example, the Math.abs() method is used to find the absolute value of the double number (-9.8). The result is then printed on the screen and it displays the value 9.8. Both of these examples use the java.util package library.