Number Class Methods List

ww‮‬w.theitroad.com

Here is a list of some commonly used methods of the Number class:

  1. byteValue(): Returns the value of the Number object as a byte.

  2. shortValue(): Returns the value of the Number object as a short.

  3. intValue(): Returns the value of the Number object as an int.

  4. longValue(): Returns the value of the Number object as a long.

  5. floatValue(): Returns the value of the Number object as a float.

  6. doubleValue(): Returns the value of the Number object as a double.

  7. equals(Object obj): Compares the Number object with the specified object for equality.

  8. toString(): Returns a string representation of the Number object.

  9. hashCode(): Returns the hash code value for the Number object.

  10. compareTo(Number anotherNumber): Compares the Number object with another Number object.

  11. isNaN(): Returns true if the value of the Number object is NaN (not a number).

  12. isInfinite(): Returns true if the value of the Number object is infinite.

These methods can be used to perform various operations on numeric values, such as converting between different data types, comparing values, and checking for special values such as NaN and infinity. Note that the Number class is an abstract class, so you cannot create instances of it directly. Instead, you can create instances of its concrete subclasses such as Integer, Double, and Long.