You are here: Home / Topics / Type Casting Example in Java

Type Casting Example in Java

Filed under: Java on 2023-08-11 19:32:57

//  Program to explain Type Casting ( Explicit Conversion )

class TypeCasting
{
public static void main( String args[ ] )
{
 int a;
 float b = 123.333f;
 System.out.println( " Before Casting = " + b );

 a = (int) b;
 
 System.out.println( " After Casting  = " + a );
}
}


Output:

Before Casting = 123.333
After Casting  = 123

About Author:
V
Vinay Kumar     View Profile
Hi, I am using MCQ Buddy. I love to share content on this website.