+ 3
why and how this is true ???
code is here đ https://code.sololearn.com/cH8U8RMZcn0E/?ref=app
10 Respostas
+ 4
Java:
I must compare an integer with a character ....
What can I dođ€đ€đ€đ€đ€
Ohhhhh wait đ€đ€đ€đ€đ€đ€...
Each character is assigned to an ascii Code, which is an Integer
đ€đ€đ€my Coder surely forgot to convert, I will do for him....
....đŻ ascii of a is 97
A clear case of true đđ» I will print the result of my thoughts ASAP...
"
+ 3
Maybe because of an implicit type convertion during comparision, either:
97 is converted to 'a' as its respective ascii code,
'a' is converted to 97 as its respective character form.
+ 3
Davinder Kumar u need upvotes for that question?
+ 2
Davinder Kumar
System.out.println((int) 'a'); //97
So when you compare char with integer it compares ASCII value of char with int value.
+ 1
+ 1
Oma Falk i think this is a platform where anyone can upload and ask their doubts right ??
+ 1
Davinder Kumar
Yes but before that use search option to get your answer. If you didn't get then ask.
+ 1
Ascii value is always in number and can be represented by a number when printed
0
AÍąJ so according to you, asking a question like that isn't a good searching way right ?? ohk got it by the way Thanks you sir.
0
This is due to type promotion of the intended to char or vice versa