byte to double Java

byte to double Java

After knowing primitive data types and Java rules of Data Type Casting (Type Conversion), let us cast byte to double.

The byte takes 1 byte of memory and double takes 8 bytes of memory. Assignment 1 byte value to 4 bytes is done implicitly by the JVM. JVM does not take any process overhead for implicit casting. This is known as automatic promotion or widening conversion. It is so simple like pouring smaller bottle water into a bigger bottle.

byte –> short –> int –> long –> float –> double

The left-side value can be assigned to any right-side value and is done implicitly. The reverse requires explicit casting.


Following program on byte to double explains implicit casting. Observe, the Java syntax of doing so.

byte to double
Output screenshot of byte to double Java

1 byte value b1 is assigned to 8 bytes d1 and is type casted implicitly.

View all for 65 types of Conversions

Leave a Reply

Your email address will not be published. Required fields are marked *