0
[answered] Comparising input strings (Java)
I have an input (scanner.nextLine()) and I enter "ABC". Why does input=="ABC" return false?
2 Réponses
+ 1
Use s1.equals(s2) to compare strings:
input.equals("ABC')
0
Because String in Java is a reference type, this means that when you use the String in your program, you are actually using its reference.
"ABC" == "ABC" actually compares the references of the strings.