Hi,
I need to have a UserProfile
class that it's just that, a user profile. This user profile has some vital user data of course, but it also needs to have lists of messages sent from the user friends.
I need to save these messages in LinkedList
, ArrayList
, HashMap
and TreeMap
. But only one at a time and not duplicate the message for each data structure. Basically, something like a dynamic variable type where I could pick the data type for the messages.
Is this, somehow, possible in Java? Or my best approach is something like this? I mean, have 2 different classes (for the user profile), one where I host the messages as Map<K,V>
(and then I use HashMap
and TreeMap
where appropriately) and another class where I host them as List<E>
(and then I use LinkedList
and ArrayList
where appropriately). And probably use a super class for the UserProfile
so I don't have to duplicate variables and methods for fields like data, age, address, etc...
Any thoughts?