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; System.out.println(b); } }
Output: