Thursday, March 27, 2008

Using the Math class

Using the Math class

 

The Math class is final and all the methods defined in the Math class are static, which means you cannot inherit from the Math class and override these methods. Also, the Math class has a private constructor, so you cannot instantiate it.

The Math class has the following methods: ceil(), floor(), max(), min(), random(), abs(), round(), sin(), cos(), tan(), and sqrt().

If you pass a negative number to the sqrt() function, it returns NaN ("Not a Number").

 

No comments:

Post a Comment