absolute value java
public class Test {
public static void main(String args[]) {
Integer a = -8;
double d = -100;
float f = -90;
System.out.println(Math.abs(a));
System.out.println(Math.abs(d));
System.out.println(Math.abs(f));
}
}abs(intx);// Java program to demonstrate working
// of java.lang.Math.abs() method
import java.lang.Math;
class Gfg {
// driver code
public static void main(String args[])
{
float a = 123.0f;
float b = -34.2323f;
double c = -0.0;
double d = -999.3456;
int e = -123;
int f = -0;
long g = -12345678;
long h = 98765433;
// abs() method taking float type as input
System.out.println(Math.abs(a));
System.out.println(Math.abs(b));
// abs() method taking double type as input
System.out.println(Math.abs(1.0 / 0));
System.out.println(Math.abs(c));
System.out.println(Math.abs(d));
// abs() method taking int type as input
System.out.println(Math.abs(e));
System.out.println(Math.abs(f));
System.out.println(Math.abs(Integer.MIN_VALUE));
// abs() method taking long type as input
System.out.println(Math.abs(g));
System.out.println(Math.abs(h));
System.out.println(Math.abs(Long.MIN_VALUE));
}
}
Also in Java:
- java variable string
- get random number from enum in java
- prime number program in java
- import collections in java
- write an object java in a file
- tolowercase java
- imageview.setbackground
- java arraylist to array
- java check if a line is enclosed in quotation marks
- cordova cannot find symbol import com.google.firebase.iid.FirebaseMessagingService;
- print int in java
- converting char array to string
- java list to set
- java insertion sort
- java sleep in code
- bitwise operator in java
- java create directory
- how to write a merge sort array method ni java
- how to create a method java
- java string length validation regex
- set java
- java find duplicates in array
- java 8 group a collections by 2 property
- for loop java