Why do we have contains(Object o) instead of contains(E e)?

前端 未结 5 1423
广开言路
广开言路 2020-12-18 20:21

Is it to maintain backwards compatibility with older (un-genericized) versions of Collection? Or is there a more subtle detail that I am missing? I see this pat

5条回答
  •  情书的邮戳
    2020-12-18 20:44

    "does that basket of apples contain this orange?"

    clearly a TRUE answer cannot be given. but that still leaves too possibilities:

    1. the answer is FALSE.
    2. the question is not well formed, it should not pass compile.

    the collection api chose the 1st one. but the 2nd choice would also make perfect sense. a question like that is a bullshit question 99.99% of times, so don't even ask!

提交回复
热议问题