Skip to content

Type Casting

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
//*********************************************************************
//We introduce casting
//*********************************************************************
public class TypeCasting{
    public static void main(String[] args){
        int mum1 = 4;
        double num2 = 5.56789;
	char ch = 'l';
	//If we change a double into integer what happens
	//We use  in order to cast a variable to other types
	System.out.println("The integer value of num2 is "+num2);
	//If we change a character into integer what happens
	//It will give the ASCII value of the character
	System.out.println("The integer value of ch is "+ch);
    }
}

Be First to Comment

Leave a Reply

Your email address will not be published. Required fields are marked *