How to find absolute value in Java

1 Answer

0 votes
public class MyClass {
    public static void main(String args[]) {
        System.out.println(Math.abs(0));
        System.out.println(Math.abs(-8));
        System.out.println(Math.abs(-0));
        System.out.println(Math.abs(193));
        System.out.println(Math.abs(3.14));
    }
}



/*
run:

0
8
0
193
3.14

*/

 



answered Aug 5, 2020 by avibootz
edited Aug 5, 2020 by avibootz
...