Can any one suggest me which collection to use for this scenario:
Every student has a payment history with details of payment made by the student / family. The system should ensure that no duplicate payments are there against a student account. The program should be able to add payment details for a student, and ensure that duplicate payment details are not getting registered.
Perhaps a
Map<Student, Set<Payment>>would do.(A
Setwon’t allow for duplicates.)If you override
equalsproperly (andhashCode) you can do something like