I have a HashMap<String, String>
, and I'm inputting an entry into the HashMap everytime a player speaks for example. Bob492 says 'Hi'. and I will be inputting 'Bob492', and 'Hi' as its value.
Now I need a way to capture the last 5 message into a their own string, one string for each.
How would I do this?
EDIT: Thanks to a reply, it seems HashMap is not the best way to do this but a queue might be better. How would I achieve this, for example.
This is a dialog. Bob: Hey Bobby: Oh there you are! Bobby: I was looking for you Joseph: Yeah, I know I know. James: I wasn't talking to you! Joseph: Who cares?!?
And that will all be put in a queue, and I can easily fetch their username and message somehow (I don't know). Only can see 5 from that 6 messages, so Bob's message would be gone.
EDIT2: I want it similar to this: