Java xxxValue () method
xxxValue () method is used to convert an object to the valuexxx Number data type and return.
Related methods are:
Types of | Method and Description |
---|---|
byte | byteValue (): Returns a byte value. |
abstract double | doubleValue (): In double Returns the specified value. |
abstract float | floatValue (): Returns a float value. |
abstract int | intValue (): Returns as int the specified value. |
abstract long | longValue (): In long form returns the specified value. |
short | shortValue (): In short form returns the specified value. |
parameter
The above function does not accept any parameters.
return value
Afterxxx converted to a numeric representation of the type of the object.
Examples
public class Test{ public static void main(String args[]){ Integer x = 5; // 返回 byte 原生数据类型 System.out.println( x.byteValue() ); // 返回 double 原生数据类型 System.out.println(x.doubleValue()); // 返回 long 原生数据类型 System.out.println( x.longValue() ); } }
Compile the above program, the output is:
5 5.0 5