Java xxxValue() Method
The xxxValue() method is used to convert a Number object to axxxvalue of the data type and return it.
Related methods are:
| Type | Method and Description |
|---|---|
| byte | byteValue() : Returns the specified numeric value as a byte. |
| abstract double | doubleValue() : Returns the specified numeric value as a double. |
| abstract float | floatValue() : Returns the specified numeric value as a float. |
| abstract int | intValue() : Returns the specified numeric value as an int. |
| abstract long | longValue() : Returns the specified numeric value as a long. |
| short | shortValue() : Returns the specified numeric value as a short. |
Parameters
None of the above functions accept any parameters.
Return Value
Converted toxxxthe value represented by this object after the type conversion.
Example
Test.java file
public class Test{
public static void main(String args[]){
Integer x = 5;
//Returns the byte primitive data type.
System.out.println( x.byteValue() );
//Returns the double primitive data type.
System.out.println(x.doubleValue());
//Returns the long primitive data type.
System.out.println( x.longValue() );
}
}
Compile the above program, the output result is:
5 5.0 5
Other Extensions
Java Number Class