+ 1
Java Output
Hi! š im A learner wants to learn and take notes on challenge questions if its okay to you guys can you guys explain to me what happens to this code?need a clearer insight.tnx in advanceš https://code.sololearn.com/ccXg3IDlpdB0/?ref=app
6 Answers
+ 3
if you still need a whole explanation this is what i can provide: so here at line 6 we declared two boolean variables b and b1 in which we declared their default values which is b=false and b1=true
at line 7 we declared char ch =65
at line 9 s1.toLowerCase().equals(s2)
toLowerCase() is a method that returns strings into lowercase and
equals() returns the comparison of two strings if they are the same.which
is true so what b will actually return is b which is inside the if statetement which is b=!b its like this b=!false which is true
and second if statement which is s1.charAt(6) specifies the char that the value represents which is 6 so when we count from 0-6 At "Sololearn" the char is 'a' which represents 97 in ASCII table so b1 is false so it will return the default value at line 6 which is true
so b=true b1=true
here is a link for ASCII Tableš
https://www.cs.cmu.edu/~pattis/15-1XX/common/handouts/ascii.html
+ 2
s1 in lower case equals s2, so b=!b = !false = true
+ 2
b1 would be false if the string would be "sololeArn" because 65 is the upper case a. Instead you might use 97 which is the lower case a
+ 1
Tnx!Haha its notedš Disorderšøšš
0
tnx but, i actually knew that part what actually confused me is line 11 and 12 though still a "Whole" explanation from anyone for this code would be appreciated.
0
tnx Aaron Eberhardt ,but there's still a doubt š¶cant marked it as solved theres something that i've been missing here id try to find by myself though.š