Can double value cast to byte

Can double value cast to byte ?

Answer : In java left hand side value can be assigned to right hand side value this is called implicit casting or variable promotion.
But reverse of implicit casting is called explicit casting and here we are not promoting value but demote it from high to low. Yes we can convert double to bye using explicit casting. Please see example below:

public class OperatorAssociativeTest {

    public static void main(String[] args) {

	double d = 55.0;
	byte b = 0;
	b = (byte) d;




Can double value cast to byte

Leave a Reply

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

I am not Robot *