0
String defining difference
Why this code gives me false?: String name1 = "Naveh"; String name2 = new String("Naveh"); Return(name1==name2);
5 Respuestas
+ 1
You need to use equals to compare strings.
Return (name1.equals(name2));
let me know how it goes
+ 1
This has been asked before, over in this thread a few people discussed the details:
https://www.sololearn.com/discuss/1624545/?ref=app
0
It worked thank you.
In general, what is the difference betwwen the two initializations?
0
The == compares if the objects are identical, equals() compares if the characters of a string match
0
It is very useful to validate passwords too,you can check by turning a letter to uppercase,the result will be false since characters won't match