why and how this is true ??? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

why and how this is true ???

code is here 👇 https://code.sololearn.com/cH8U8RMZcn0E/?ref=app

14th Aug 2022, 4:10 PM
Davinder Kumar
Davinder Kumar - avatar
10 Answers
+ 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... "
14th Aug 2022, 4:20 PM
Oma Falk
Oma Falk - avatar
+ 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.
14th Aug 2022, 4:22 PM
Ervis Meta
Ervis Meta - avatar
+ 3
Davinder Kumar u need upvotes for that question?
14th Aug 2022, 4:42 PM
Oma Falk
Oma Falk - avatar
+ 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.
14th Aug 2022, 4:24 PM
A͢J
A͢J - avatar
+ 1
A͢J Oma Falk Ervis Meta - SoloHelper how good this question is ? right
14th Aug 2022, 4:27 PM
Davinder Kumar
Davinder Kumar - avatar
+ 1
Oma Falk i think this is a platform where anyone can upload and ask their doubts right ??
14th Aug 2022, 5:51 PM
Davinder Kumar
Davinder Kumar - avatar
+ 1
Davinder Kumar Yes but before that use search option to get your answer. If you didn't get then ask.
15th Aug 2022, 2:57 AM
A͢J
A͢J - avatar
+ 1
Ascii value is always in number and can be represented by a number when printed
15th Aug 2022, 10:38 AM
Yuvraj
Yuvraj - avatar
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.
15th Aug 2022, 7:51 AM
Davinder Kumar
Davinder Kumar - avatar
0
This is due to type promotion of the intended to char or vice versa
15th Aug 2022, 4:47 PM
Albright 65
Albright 65 - avatar