Facebook Page Twitter Page LinkedIn Page
× Java.lang Package Classes

The java.lang.Double.byteValue() method is used to return the value of this Double as a byte after a narrowing primitive conversion.


public byte byteValue()


No parameter is required.

Return Value

Returns the double value represented by this object converted to type byte.




In the below example, the java.lang.Double.byteValue() method is used to return a Double object after conversion to type byte.

import java.lang.*;

public class MyClass {
  public static void main(String[] args) {
    //creating Double objects
    Double val1 = new Double("25.6");
    Double val2 = new Double("-25.6");

    //printing byteValue of the Double objects
    System.out.println("byteValue of the val1 is: " + val1.byteValue()); 
    System.out.println("byteValue of the val2 is: " + val2.byteValue());   

The output of the above code will be:

byteValue of the val1 is: 25
byteValue of the val2 is: -25

❮ Java.lang - Double