absolute value in java
Java
// 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));
}
}
abs(intx);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));
}
}
Also in Java:
- Title
- java 8 retrieve all list from object into single list and ignore duplicates
- Category
- Java
- Title
- java clear bufffer to take next string inpuit
- Category
- Java
- Title
- java how to put a string sentence in a map
- Category
- Java
- Title
- read lines of file randomly java
- Category
- Java
- Title
- expression régulière téléphone java
- Category
- Java
- Title
- java remove first character from string
- Category
- Java
- Title
- rock paper scissors java
- Category
- Java
- Title
- java lambda list of objects cast
- Category
- Java
- Title
- how to make a fixed size array in java
- Category
- Java
- Title
- programa que convierete un archi de c a java
- Category
- Java
- Title
- how to remove duplicates from an array java
- Category
- Java
- Title
- how to create a JFrame in java
- Category
- Java
- Title
- file with line numbers inserted java
- Category
- Java
- Title
- how to have a only number type in java
- Category
- Java
- Title
- how to get witdth of window android
- Category
- Java
- Title
- in dom parser how to find processing instruction in java
- Category
- Java
- Title
- java script using navigator.useragent to detect the browse
- Category
- Java
- Title
- java get last char of string
- Category
- Java
- Title
- java mockito print called methods
- Category
- Java
- Title
- java map iteration
- Category
- Java
- Title
- java string to int
- Category
- Java
- Title
- socket programming in java
- Category
- Java
- Title
- jq selector body
- Category
- Java
- Title
- how to print the map in java
- Category
- Java
- Title
- how to check if the file has remaining without reading from it java
- Category
- Java
- Title
- jsonobject to java object
- Category
- Java
- Title
- How to make a class in Java?
- Category
- Java
- Title
- creating random color in java
- Category
- Java
- Title
- loop through array java
- Category
- Java
- Title
- dictionary in java
- Category
- Java
- Title
- java android development get element by id
- Category
- Java
- Title
- capitalize string java
- Category
- Java
- Title
- has been compiled by a more recent version of the Java Runtime (class file version 56.0), this version of the Java Runtime only recognizes class file versions up to 55.0
- Category
- Java
- Title
- java stack peek
- Category
- Java
- Title
- java string array
- Category
- Java
- Title
- how intent
- Category
- Java
- Title
- how to convert string to double in android studio
- Category
- Java
- Title
- transition java fx
- Category
- Java
- Title
- how to do sex java
- Category
- Java
- Title
- reading in lines from a file java
- Category
- Java
- Title
- get sha key android
- Category
- Java
- Title
- java insertion sort
- Category
- Java
- Title
- import java.util.*;
- Category
- Java
- Title
- how to play an audio in java
- Category
- Java
- Title
- graal.js pass javascript array to java function
- Category
- Java
- Title
- async in fragment
- Category
- Java
- Title
- how to change actionbar color in android programmatically
- Category
- Java
- Title
- check if user has internet connection in kotlin
- Category
- Java
- Title
- java replaceall single character
- Category
- Java
- Title
- how to create java jframe in eclipse
- Category
- Java
- Title
- boolean java.lang.String.equals(java.lang.Object)' on a null object reference
- Category
- Java
- Title
- how to compare two maps in java
- Category
- Java
- Title
- java ternary operator
- Category
- Java
- Title
- java output array lists to file
- Category
- Java
- Title
- biginteger in java
- Category
- Java
- Title
- java list contains object with property
- Category
- Java
- Title
- joptionpane fonctionnement java
- Category
- Java
- Title
- what it means when create final variable in java
- Category
- Java
- Title
- array methods in java
- Category
- Java
- Title
- java find if element of list in present in another list
- Category
- Java
- Title
- Common GIt Commands
- Category
- Java
- Title
- do statement java
- Category
- Java
- Title
- convert char to string java
- Category
- Java
- Title
- Java Read Files
- Category
- Java
- Title
- imageview.setbackground
- Category
- Java
- Title
- how to create a draw Rectangle in java
- Category
- Java
- Title
- java how to make a gui
- Category
- Java
- Title
- loop and save letters in a string java
- Category
- Java
- Title
- change fab image programatically
- Category
- Java
- Title
- java integer to binary string
- Category
- Java
- Title
- java time code
- Category
- Java
- Title
- java how to get all threads
- Category
- Java
- Title
- java arraylist to array
- Category
- Java
- Title
- how to check if an arraylist contains a value in java recursion
- Category
- Java
- Title
- what is static setter and getter examples in java
- Category
- Java
- Title
- how to use pow function in java
- Category
- Java
- Title
- how to draw a line in java
- Category
- Java
- Title
- java save string in text file
- Category
- Java
- Title
- java while
- Category
- Java
- Title
- map.keyset in java
- Category
- Java
- Title
- java manacher's algorithm
- Category
- Java
- Title
- treeset java descending order using comparator
- Category
- Java
- Title
- log10 in java
- Category
- Java
- Title
- write file java
- Category
- Java
- Title
- how to take input in java
- Category
- Java
- Title
- how to set a windows background image tkinter
- Category
- Java
- Title
- login and logout react native and firebase
- Category
- Java
- Title
- print a string java
- Category
- Java
- Title
- find the day of the week Calendar class in java
- Category
- Java
- Title
- how to make a dictionary in java
- Category
- Java
- Title
- java connect to mysql
- Category
- Java
- Title
- Java's BigInteger class
- Category
- Java
- Title
- Java app development
- Category
- Java
- Title
- how to cut a certion part from a string in java
- Category
- Java
- Title
- how to read to into a file in java
- Category
- Java
- Title
- java method overriding
- Category
- Java
- Title
- download spring
- Category
- Java
- Title
- how to find powers in java
- Category
- Java
- Title
- how to make a button disapear on click in javafx
- Category
- Java
- Title
- Java how to handle HTTP GET request after establishing TCP connection
- Category
- Java