I tried
'''
Object b = 3;
char cdd = (Character) b;
System.out.print(cdd);
'''
but it has the following error. Exception in thread "main" java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.Character How can I fix it?
I tried
'''
Object b = 3;
char cdd = (Character) b;
System.out.print(cdd);
'''
but it has the following error. Exception in thread "main" java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.Character How can I fix it?
First cast to int and after that to char
Object b = 98;
int cdd = (int) b;
System.out.println(cdd);
System.out.println((char) cdd);
Output is
98
b