Easy Tutorial
❮ File Read Java Arraylist Indexof ❯

Java xxxValue() Method

Java Number Class


The xxxValue() method is used to convert a Number object to the xxx data type and return its value.

Related methods include:

Type Method and Description
byte byteValue() : Returns the specified number as a byte.
abstract double doubleValue() : Returns the specified number as a double.
abstract float floatValue() : Returns the specified number as a float.
abstract int intValue() : Returns the specified number as an int.
abstract long longValue() : Returns the specified number as a long.
short shortValue() : Returns the specified number as a short.

Parameters

None of the above methods accept any parameters.

Return Value

The value of the object converted to the xxx type.

Example

Test.java File

public class Test{ 

   public static void main(String args[]){
      Integer x = 5;
      // Returns the primitive byte data type
      System.out.println( x.byteValue() );

      // Returns the primitive double data type
      System.out.println(x.doubleValue());

      // Returns the primitive long data type
      System.out.println( x.longValue() );      
   }
}

Compiling the above program will output:

5
5.0
5

Java Number Class

❮ File Read Java Arraylist Indexof ❯