Type Casting

 Type Casting

Type Casting:

                Converting one data type into another data type is knowns as Type casting.
All the 8 primitives datatype except boolean we can convert from one datatype to another datatype.

Types of Type casting:
  1. Inplicit type casting
  2. Explicit type casting
1. Implicit type casting:
  • It is a process of Converting smaller datatype to larger datatype is known as Implicit type casting. It is also known as Widening.
  • Implicit type casting is done by compiler automatically.
  • There is no loss of information in implicit type casting.

2. Explicit type casting:

  •  It is a process of converting larger datatype to smaller datatype is known as Explicit type casting. It is also known as narrowing.
  • Explicit type casting will not be performed by the compiler, it is the responsibility of the programmer.
  • There may be chance of loss of information.

Byte-> short, int, long, float, double.
short-> int, long, float, double.
char-> int, long, flost, double.
int-> long, float, double.
long-> float, double.
float-> double.


Comments

Popular posts from this blog

OOP's Concepts

Basics about Core Java

Data types and Variables