abs() Method in java Example 2

Java Programming Language / Number Class in java

845

Program:

 public class AbsMethod {

 public static void main(String args[]) {
	 
 Integer a = -8;
 double d = -100;
 float f = -90;
 long l = -7878l;
 byte b = -84;
 short s = -4;

 System.out.println(Math.abs(a));
 System.out.println(Math.abs(d));
 System.out.println(Math.abs(f));
 System.out.println(Math.abs(l));
 System.out.println(Math.abs(b));
 System.out.println(Math.abs(s));

   }
}

Output:

8
100.0
90.0
7878
84
4
Press any key to continue . . .

This Particular section is dedicated to Programs only. If you want learn more about Java Programming Language. Then you can visit below links to get more depth on this subject.