When should I use generics to define relationships between types?

前端 未结 6 1363
隐瞒了意图╮
隐瞒了意图╮ 2020-12-08 21:50

Getting into a little bit of confusion here when to use generics. I\'ve looked at Java Generics? but still have a few questions.

Say I have:

public          


        
6条回答
  •  死守一世寂寞
    2020-12-08 22:09

    A person is generally not parameterized with a type of car. Only very annoying persons are defined by their car. Persons change cars too (in time). So I would not parameterize the class, if only for the semantics.

    Think about what you try to mimic from the real world, before going into such programming details.

提交回复
热议问题