There are quite a few questions where the answer is the same as the answer to another (generally far more generic) question. A common example is a Java question where the OP is reporting some malfunction in his code. The root cause ends up being an incorrect String equality comparision, i.e. if (str == "value")
.
I know that it's frowned upon to answer duplicate questions, but the matter is that the OP probably didn't know it was a duplicate when he posted.
Indeed, the reference question for this issue (How do I compare strings in Java?) has a title which is precise and correct, but actually so precise that I would guess it's difficult to find unless you already understood the problem!.
(As an aside, I understand that if you actually debugged your code line-by-line you would find the issue, or at least something that "should work, but doesn't" leading to finding the proper question -- but then again, that probably applies for most, if not nearly all, questions on this site).
So, what would be a good course of action?
- Answering the question, explaining the error (adding a link to the reference question).
- Commenting, explaining the error (adding a link to the reference question).
- Marking it as duplicate with no further comment.
- Wait a prudent time for the OP to acknowledge the answer, then mark as duplicate.
- Any combination of the above?