7

Here's the example

The question, as I interpret it, is:

Why, given this conceptually correct implementation of hashCode and equals, are two instances of the class not considered equal when added as keys to this HashMap?

It's a very specific question where the error lies in incorrectly overloading the equals method.

The answer here

Hash code does not provide a unique value. Different objects can have the same hashCode().

The function hashCode() is used by Hash* (HashSet, HashMap, ...) to get a hint into which bin an object should be placed. If there are more than one objects in any one bin, all are tested using the equals function.

So even if you did overwrite hashCode() with a constant function, hashing would functionally return correct results. At (high) costs on performance, though.

discusses the general contract of Java's hashCode method and how it's used in some collections, but I don't read it as attempting to answer the question at all.

I first commented on the answer to explain that it didn't address the problem or answer the question. No edits were made on the question, so I flagged as "Not an answer". The flag was declined.

Maybe I'm misinterpreting the answer, but it doesn't seem like it attempts to answer the question. Note that the content is technically correct, but not very relevant considering that the OP had explained their expectations of hashCode.

In a more general case, where an answer discusses general computer science concepts or language constructs, but doesn't address the problem in the question, should that answer be considered an answer?

8
  • Someone needs to nuke that comment thread.
    – gunr2171
    Commented Nov 13, 2014 at 17:10
  • 1
    From an uninformed point of view, the question does address the question, so I can expect an NAA or VLQ flag to fail.
    – gunr2171
    Commented Nov 13, 2014 at 17:13
  • 1
    I've had these flags declined as well. A large piece of the problem is that reviewers don't necessarily know anything about the topic, nor do they always look at the question. Its not one of the "obvious deletion" posts, so the flag is declined. Not really sure if there is a way to fix this, as such asnwers really aren't answers. Commented Nov 13, 2014 at 17:13
  • @BradleyDotNET The declined text says it was reviewed by a moderator. I'm guessing that's not the same message as I'd get for 4 other normal members disputing it. Commented Nov 13, 2014 at 17:15
  • Even so; moderators are even more busy, and so fall prey to the same issues. Commented Nov 13, 2014 at 17:16
  • 3
    @BradleyDotNET These flags are going to be declined because declining the flag is the correct course of action. People reviewing flags aren't going to be evaluating the technical accuracy of an answer because it's not their place to do so. Flagging an answer for just being wrong or failing to answer the question is an invalid flag.
    – Servy
    Commented Nov 13, 2014 at 17:19
  • Please be mindful of the fact that the poster of that answer has a rant on his profile page where he's upset that he's "making enemies". Apparently he thinks he's being picked on personally, though he isn't, but when he logs on (he hasn't been on for three days) and sees this meta thread it won't improve his mood.
    – Boann
    Commented Nov 13, 2014 at 21:53
  • @Boann Bah, no meta effect here, except maybe some deleted comments. Commented Nov 13, 2014 at 22:22

1 Answer 1

7

The answer fails to answer the question, but it attempts to answer the question. That's not NAA. NAA is for a post that doesn't even attempt to answer the question.

When you feel an answer fails to answer the question the correct course of action is to downvote, not flag.

8
  • 1
    So I'd like to know how it attempts to answer the question. The way I interpret it, it doesn't. Commented Nov 13, 2014 at 17:18
  • And regardless of this specific case, what do you do in the general case? Commented Nov 13, 2014 at 17:20
  • 2
    @SotiriosDelimanolis The test is very easy. Does the person who posted the answer think they answered the question? Here the author thinks that he answered the question, because he interpreted the question differently from you. The fact that they interpreted the question differently, and thus provided an answer that you don't think is correct, doesn't make it Not An Answer. It makes it an answer that you feel is not correct.
    – Servy
    Commented Nov 13, 2014 at 17:20
  • @SotiriosDelimanolis I am speaking in the general case. If you feel that an answer is incorrect, or otherwise fails to answer the question, downvote it. If it doesn't even attempt to answer the question, then flag it as NAA.
    – Servy
    Commented Nov 13, 2014 at 17:20
  • Then it's that definition of attempt that I'm struggling with. Commented Nov 13, 2014 at 17:23
  • 2
    Related: meta.stackoverflow.com/a/268378 (super coincidence that the topics of the linked questions are nearly the same)
    – gunr2171
    Commented Nov 13, 2014 at 17:24
  • @SotiriosDelimanolis The way I see it: Does the "answer" look like an answer? Even if it is not to the specific question asked, if the answer to that question is "yes" then it is at least an attempt to answer the question. The exception there is if it is an obvious spam answer, in which case flag as such.
    – Kendra
    Commented Nov 13, 2014 at 17:26
  • 4
    @SotiriosDelimanolis Indeed. You seem to be conflating "attempt" with "successful attempt". A failed attempt to answer the question is still an attempt to answer the question.
    – Servy
    Commented Nov 13, 2014 at 17:26

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .