Java.lang.Number Class


Advertisements

Introduction

The java.lang.Number class is the superclass of classes BigDecimal, BigInteger, Byte, Double, Float, Integer, Long, and Short.The Subclasses of Number must provide methods to convert the represented numeric value to byte, double, float, int, long, and short.

Class Declaration

Following is the declaration for java.lang.Number class −

public abstract class Number
   extends Object
      implements Serializable

Class constructors

Sr.No. Constructor & Description
1

Number()

This is the Single Constructor.

Class methods

Sr.No. Method & Description
1 byte byteValue()

This method returns the value of the specified number as a byte.

2 abstract double doubleValue()

This method returns the value of the specified number as a double.

3 abstract float floatValue()

This method returns the value of the specified number as a float.

4 abstract int intValue()

This method returns the value of the specified number as a int.

5 abstract long longValue()

This method returns the value of the specified number as a long.

6 short shortValue()

This method returns the value of the specified number as a short.

Methods inherited

This class inherits methods from the following classes −

  • java.lang.Object
Advertisements