Home >>Java Programs >Typecasting in Java
In this example, we will see a Java program in which we will do the typecasting in java.
Typecasting term is introduced in all the languages similar to java. It is the process of assigning primitive datatype to another datatype.
Program:
public class Main
{
public static void main(String[] args)
{
int num1;
double num2 = 202.81;
// We are assigning larger size datatype
// long to smaller size datatype
num1 = (int) num2;
// Print the output
System.out.println("The value of num1 is :" + num1);
}
}