Home » , » Java Type Casting

Java Type Casting

 Java Type Casting

The Primitive datatypes in Java are the following: byte, short, int, long, float, double, boolean, and char. Type Casting is to convert one data type to another. There are two types of Type Casting in Java:


  • Automatic Type Casting
  • Manual Type Casting

Automatic/ Widening Type Casting in Java

The Widening type casting is handled by Java on its own i.e., it occurs when you want to convert a smaller type to a larger type.


The flow for Widening type casting in Java includes:






Let us see an example of the Automatic/ Widening Type Casting in Java:




Output


Manual/ Narrowing Type Casting in Java

The narrowing type casting is handled by Java on its own i.e., it occurs when you want to convert a larger type to a smaller type.

The flow for Automatic type casting in Java includes:











Let us see an example of the Manual/ Narrowing Type Casting in Java:


Output




0 comments:

Post a Comment

Popular Posts

GENRES

 
Copyright ©

latest code update bloggingskillBest coding website in india

Created By Sora Templates | Distributed By Gooyaabi Templates