Type Casting in Java


Type casting is a way of converting data from one data type to another data type. This process of data conversion is also known as type conversion.

Source Code

//04 Type Casting in Java
/*
	Widening Casting
		byte -> short -> char -> int -> long -> float -> double
	Narrowing Casting
		double -> float -> long -> int -> char -> short -> byte
*/
import java.lang.*;
 
class casting
{
	public static void main(String args[])
	{
		int a=10;
		double b=a,d=25.5385;
		int c=(int)d;
		System.out.println("Int : "+a);
		System.out.println("Double : "+b);
		System.out.println("Double : "+d);
		System.out.println("Int : "+c);
 
 
 
 
	}
}
To download raw file Click Here

Basic Programs



Learn All in Tamil © Designed & Developed By Tutor Joes