+ 9

Can anyone please explain me the first operand of AND operator in the following code?

solo s1=new solo (); solo s2=new solo (); String str1="abcd", str2="abcd"; if(s1.equals (s1)&&str1.equals (str2)){ s.o.p ("ab"); else s.o.p ("cd");

8th Oct 2017, 5:17 AM
Panda Lad
Panda Lad - avatar
8 Réponses
0
mine is (Hari P Sharma)
31st May 2018, 3:00 PM
Hari Prasad Acharya
Hari Prasad Acharya - avatar
+ 8
You created two new instances of your class 'solo' namely s1 and s2. You have two String literals str1 and str2 which are equal (as "abcd"). * Then, you check if instance s1 is equal to s1 (always true) and str1 is equal to str2, the result will be true of course. Therefore, it prints ab as the result. You made a typo there as well, you should close the 'if' code block before entering into 'else'.
8th Oct 2017, 5:57 AM
Dev
Dev - avatar
+ 7
thank you so much dev
8th Oct 2017, 12:34 PM
Panda Lad
Panda Lad - avatar
+ 2
Wee hee
10th Oct 2017, 3:32 AM
Kye Joseph
Kye Joseph - avatar
+ 1
its the same dear
30th May 2018, 9:06 PM
Panda Lad
Panda Lad - avatar
+ 1
wait ill send you request
31st May 2018, 2:59 PM
Panda Lad
Panda Lad - avatar
0
hey Jigme sis.. can i get ur fb name???
29th May 2018, 2:16 AM
Hari Prasad Acharya
Hari Prasad Acharya - avatar
0
school gacha mo ashim??? fb nga
31st May 2018, 2:55 PM
Hari Prasad Acharya
Hari Prasad Acharya - avatar