Type Casting in Java | Core Java Tutorials

This Core Java Tutorials  “Type casting in java” post explains clearly what is type casting and classification of type casting including implicit and explicit type casting with examples in Java.


 

Type casting:

  • Conversion of data from one data type to another data type.
  • Type Casting will be done at runtime.
  • Java allows Primitive casting and Object casting
  • Casting can be either Implicit or Explicit.
  • Implicit casting (internal) done by JVM
  • Explicit casting (external) done by Programmer.

 

Implicit casting : Converting Lower data type into Higher type
  1. byte to int
  2. byte to short
  3. short to int
  4. char to int
  5. int to float

 

Explicit casting : Converting Higher type data into Lower type
  1. int to char
  2. int to byte

Type Casting in Java

Share this