+ 1
"0" != "0" Java (на русском, українській тоже пишите/також пишіть)
I wrote my code in Java, and when testing it, I realized that "0" != "0", here is this part of the program: m = input.next() if (m == 0){ ... This code in 'if' does not work. I checked it out of the program and it really is, why?
3 Antworten
+ 7
When using "string1==string2", Java checks if both strings have the same address in memory. Instead you should use "string1.equals(string2)" to check if two strings have the same content
This is because String isn't a data type but it's a class containing an array of chars and a punch of methods.
+ 1
Thank you!
0
welcome :D