Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

How do ArrayList work> i heard they can store data and thats about all i know

+1 vote
asked Dec 9, 2019 by GibberishLove02 (130 points)
i am tryimng to do a login program and want to use system.in so the user can make a username and passowrd, but have no idea how to store that and use it.

1 Answer

0 votes
answered Dec 9, 2019 by Theodore Friedrich (290 points)

You would be better off using a HashMap for username's and passwords. HashMaps store data in using keys. If you had this HashMap:

{"billybob"="password", "sk8rboi69"="password#2"}

You could access the data by using .get("billybob").

Example

HashMap<String, String> users = new HashMap<String, String>(); //<type of key, type of value>

users.put("billybob", "password");

System.out.println(users); // {"billybob"="password"}

System.out.println(user.get("billybob")); // "password"

Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...