Explicit Casting Programs in Java | Java Tutorials

This Java Tutorials “Explicit casting programs in Java” post explains clearly how to convert int type to byte type when we try to assign a value which is beyond the limits of byte range.


 

Explicit Casting:

  • This program explains clearly how to convert int to byte.
  • This program explains what value will be stored inside byte variable when we assign a value which is out of bounds.
  • How it stores int value into byte variable using limits.

 

Explicit Casting in Java

 

One more example of Type casting:

 

One more example that describes how negative value will be stored into byte variable:

Explicit casting diagram for above program

 

Share this