What should be the output of the program?? | Sololearn: Learn to code for FREE!
Новый курс! Каждый программист должен знать генеративный ИИ!
Попробуйте бесплатный урок
+ 1

What should be the output of the program??

According to me output should be hello but it showing world... Help me https://code.sololearn.com/c02wp0308i9H/?ref=app

6th Apr 2020, 6:15 AM
Prakhar
5 ответов
+ 6
Prakhar == compare object not value. To check valve you need to use equals method. Check here how we can compare String in java. https://code.sololearn.com/cZms6c3vg2w3/?ref=app
6th Apr 2020, 6:29 AM
A͢J
A͢J - avatar
+ 3
I know, this happened to me too, frustrating, but I found out. You shouldn't use == when comparing strings in java Instead use .equals() if(ch.equals("hello"))
6th Apr 2020, 6:18 AM
maf
maf - avatar
+ 2
Thanks to all of you..
6th Apr 2020, 6:41 AM
Prakhar
+ 2
In Java string is an object rather than arrays of chars and primitive types. So you need a different method called String.equals() method.
6th Apr 2020, 1:18 PM
0_O-[Mägár_Sám_Äkà_Nüllpøïntêr_Èxëcéptïön]~~
0_O-[Mägár_Sám_Äkà_Nüllpøïntêr_Èxëcéptïön]~~ - avatar