+ 2
Why I get false as output. Please explain
https://code.sololearn.com/cLJON9cPQ94j/?ref=app Why does it give false outpu as value and memory both are same of the String variable.
8 Respostas
+ 3
The (==) checks the equality of two primitive data type values since String is not primitive data type in Java we use the equals() function for it!
your code must be like this:
System.out.println(c.equals(d));
+ 2
Ayush Pandey
Difference of String equality check?
See the code and tell me why in first case both are equal Strings but in second case both are not equal Strings?
String text1 = "ahmad";
String text2 = "ahmad";
text1.equals(text2); // returns true
String text1 = "ahmad";
String text2 =new String("ahmad") ;
text1.equals(text2); // returns false
+ 2
Eqbal Sharaf here you can get your answer, read all the answers and questions from start to end
+ 1
https://www.sololearn.com/discuss/1801000/?ref=app
Saboor Hakimi and Russel Campollo then why does this gives true output
+ 1
Ayush Pandey this question is the answer of your question!
+ 1
Saboor Hakimi yes you r taking my question right
+ 1
Saboor Hakimi may be it is false cause one is variable and other is data type. Not quite sure. This topic to be honest is not quite clear yet.