+ 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
5 Réponses
+ 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
+ 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"))
+ 3
to compare strings in Java, use
ch.equals("hello") instead.
https://www.sololearn.com/discuss/1651043/?ref=app
https://www.sololearn.com/discuss/911771/?ref=app
https://www.sololearn.com/discuss/63147/?ref=app
https://www.sololearn.com/discuss/853481/?ref=app
+ 2
Thanks to all of you..
+ 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.