Math. abs it's a process that takes the accurate value from the user.
if the user give input x= -78
then if we use (Math.abs(x));
it' will be printed only x=78
Syntax:
Parameters:
Return:
Example 1:
- public class AbsExample1
- {
- public static void main(String args[])
- {
- int x = -48;
- //print the absolute value of int type
- System.out.println(Math.abs(x));
- }
- }
Output
48