Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Java Java-get-example Get Absolute Value

Related Tutorials


 
 

Share on Google+Share on Google+

Get Absolute Value

Advertisement
Absolute value is the only value of a number regardless of a prefixed plus or minus sign.

Get Absolute Value

     

Absolute value is the only value of a number regardless of a prefixed plus or minus sign. In the example given below we have used abs() method of class java.lang.Math that returns absolute value  of a given number as argument. We can use abs() method for double, float, int, long type values.

 

 

 

 

public class GetAbsoluteValue {
 public static void main(String args[]) throws Exception {
  double value = Math.abs(-10);
  double value1=Math.abs(50);
  System.out.println("The absolute value of -10 is: "+value);
  System.out.println("The absolute value for the condition is: "+value1);
  }
}

Output will be displayed as:

Download Source Code

Advertisement

If you enjoyed this post then why not add us on Google+? Add us to your Circles



Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: October 22, 2008

Related Tutorials

Discuss: Get Absolute Value   View All Comments

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments:2
ABHISHEK SHEKHAR
October 12, 2011
Memory Management

How to get to know that how much memory is allocated to a program by os for its execution? And how to demand for the extra memory
***maryam
August 31, 2012
$$$

java codis
DMCA.com