java.lang.Double byteValue()


public byte byteValue()

Java Code Example :

This java example source code demonstrates the use of byteValue() method of Double class.

Some takeaways on the byteValue method:

  • override the byteValue in class Number
  • since JDK 1.1

 * This example source code demonstrates the use of  
 * byteValue() method of Double class

public class DoubleByteValue {

	public static void main(String[] args) {

		Double val = 321.25;
		byte result = val.byteValue();
		System.out.println("Double "+val + " byte value="+result);
		Double anotherValue = 321.0;
		byte anotherResult = anotherValue.byteValue();
		System.out.println("Double "+anotherValue + " byte value="+anotherResult);		
		 * You would have noticed that the result would be the same
		 * because the decimal places has been truncated as 
		 * specified in the method description


Sample Output :

Running the above example source code will give the following output

Double byteValue() method example

Double byteValue() method example

Suggested Reading List :

References :