Generic pair class

后端 未结 14 1671
情话喂你
情话喂你 2020-12-01 16:49

Just attempting this question I found in a past exam paper so that I can prepare for an upcoming Java examination.

Provide a generic class Pair for representing pair

14条回答
  •  遥遥无期
    2020-12-01 17:24

    Usually a generic Pair type has two generic type parameters, not one - so you could have (say) a Pair. That's typically more useful, IMO.

    I would also suggest that you think about a more conventional name for your type parameter than "thing". For example, you might use Pair or Pair.

提交回复
热议问题