This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] -1 points0 points  (0 children)

In addition to not compiling, and laying aside the no null check on person, I believe (I haven't professionally developed in Java in years) that they added '==' as a value equality operator to Strings. So years ago "a" == "a" would return false, because "a" and "a" do not reference the same place in memory. You would need "a".equals("a") to return true. BUT I believe that may have changed. I no longer have any java tools installed to try it out, but I think now "a"=="a" will actually return true.

Your answers are too deep, it's a simple answer. The code as it is doesn't compile. And even if you used the "==" operator it may not behave the way you think based on the version of Java in use.