Friday, May 19, 2017

Casting in Java

Casting in Java is the process to convert one data type to another.

An example of casting can be like:

long c = 8L;
int a = c;

Casting can be broadly classified into two types:

1. Implicit Casting: It is done by the compiler
2. Explicit Casting: It is done by code

Eg:

    long c = 8L;
    int a = c; //implicit casting
    int b = (int) c; //explicit cast




No comments:

Post a Comment