java tutorial - Java xxxValue() Method - java programming - learn java - java basics - java for beginners
![Java numbers xxxvalue](https://wikitechy.com/tutorials/java/img/java-images/java-numbers-xxxvalue.gif)
Learn Java - Java tutorial - Java numbers xxxvalue - Java examples - Java programs
Description
The xxxValue () method - It converts to Java the numeric value of the object that invokes the method, into a primitive data type that is returned from the method.
Syntax
- At this point, each primitive data type denotes a separate method:
byte byteValue () // Convert to byte
short shortValue () // Convert to short
int intValue () // Convert to int
long longValue () // Convert to long
float floatValue () // Convert to float
double doubleValue () // Convert to double
click below button to copy the code. By - java tutorial - team
Options
Detailed information about the parameters:
- They are the default methods and do not transmit any parameter.
Return value
- The xxxValue () method in Java returns a primitive data type that is specified in the signature.
Sample Code
public class Test {
public static void main (String args []) {
Integer x = 5;
// Convert int to byte and return a primitive data type byte
System.out.println (x.byteValue ());
// Converts an int to double and returns a primitive data type double
System.out.println (x.doubleValue ());
// Convert int to long and returns a primitive data type long
System.out.println (x.longValue ());
}
}
click below button to copy the code. By - sql tutorial - team
Output
5
5.0
5