Hi Friends,
Today, we are going to see about how to store character in ‘int’ variable and number in ‘char’ datatype.

Let us see it through a sample program below.

public class IntAndChar {
public static void main(String[] args) {
int a=’A’;
char b=70;
System.out.println(a);
System.out.println(b);
}
}

Output:
65
F
this output can be possible because,

ASCII              Character
——————————-
65                      A
66                      B
67                      C
int a =’A’;
‘A’ convert into its 65(ASCII) and store into integer variable a.

char b=70;
70(ASCII) convert into character ‘F’ and store into char variable b.