Reputation: 55
I am writing a simple server client application where the server class runs single time and the client runs multiple times.
As the clients keep coming and for each clients, I assign a name and send it to the server. There is also a client handler class for handling them.
But the issue is I am trying to save the password and username of a client to an arraylist
and every time I run the Client class it creates new object of that arraylist
and for each run, two of the logins are not saved in the same arraylist
.I know I can implement login system by implementing database or saving those strings into a file but my question is, how can I save multiple class run information into a single arraylist
?
Upvotes: 0
Views: 97
Reputation: 31
Every time you start a new instance of the application running your client class, new lists are created for that instance. If you want to keep all the information in main memory, you need a ClientHandler-Program running only once that keeps track of your client credentials.
Upvotes: 1