Java many to many association map

前端 未结 7 1038
难免孤独
难免孤独 2020-12-16 01:29

I have two classes, ClassA and ClassB, as well as a \"many to many\" AssociationClass. I want a structure that holds the associations

7条回答
  •  独厮守ぢ
    2020-12-16 01:38

    Using your AssociationClass, you could just have ClassA and ClassB both contain a reference to AssociationClass:

    private AssociationClass association;
    

    Or, a different method...

    ClassA can contain:

    private List classBList;
    

    and ClassB can contain:

    private List classAList;
    

    By implementing this, you can access your associations from within the associated class.

提交回复
热议问题