How to create an ArayList with a different name each type?

I am new to programming and I am currently learning Java. I am using ArrayList to create string arrays to store messages to specific "accounts" in this case. Whenever some registers an account in my program I want it to create a new ArrayList to store messages sent to them. It would essentially use Buffered Reader to take in the username and then create an ArrayList with the name of what the user just entered. I'm not sure if this is even possible so that's why I'm asking thanks in advance.

String username = bufferedReader.readLine();
ArrayList<String> "username" = new ArrayList<String>();
Jon Skeet
people
quotationmark

I'd first advise you to take note of the fact that you're referring to these objects as accounts - that suggests you should quite possibly have an Account type, which contains the List<String> of messages. Aside from anything else, this means you could start adding more information to the account as well.

Next, you can't give variables names dynamically... but if you want to be able to have multiple accounts, and find them by username quickly, that sounds like a Map<String, Account>. It would probably be worth making the username another field within the Account as well.

So you'd then have something like:

// Early on
Map<String, Account> accountsByUsername = new HashMap<>();

// Then in a loop, or whatever
String username = bufferedReader.readLine();
accountsByUsername.put(username, new Account(username));

Later again, you can get the account for a given username with:

Account account = accountsByUsername.get(username);
// Now account will be null (no such user), or a reference to the user's account.

people

See more on this question at Stackoverflow