Programming a one-to-many relationship

后端 未结 8 806
醉话见心
醉话见心 2020-12-25 08:16

So I am surprised that doing a search on google and stackoverflow doesn\'t return more results.

In OO programming (I\'m using java), how do you correctly implement a

8条回答
  •  臣服心动
    2020-12-25 08:30

    Just implement some sort of collection in the object that has the other objects For example in customer you could say:

    private List jobs; 
    

    then by using getters and setters you can add values jobs to this list. This is basic OO stuff, I don't think you searched enough on the internet. there is a lot of info available on these subjects.

    Btw, you can use all sort of collections (Sets, Lists, Maps)

提交回复
热议问题