I have a two input text field window in which users input an ID and Password. I then need to compare these passwords to allowable users. What would be the best method for associating each unique password with its specific user id?

Do you have somewhere the usernames and passwords stored? If yes when the user enters username amd password compare those values with the ones you have saved.

Do you have somewhere the usernames and passwords stored? If yes when the user enters username amd password compare those values with the ones you have saved.

To test the functionality of the rest of the program, I just have a single user name and password hard-coded in. It can not authenticate multiples. How the valid pairs should be saved is what I am wondering. 2 basic arrays, a 2-D array, linked list?

To test the functionality of the rest of the program, I just have a single user name and password hard-coded in. It can not authenticate multiples. How the valid pairs should be saved is what I am wondering. 2 basic arrays, a 2-D array, linked list?

imho the best way to store them, would be in a database which is used by the application

I assume for testing you have something like this:

String username = ... ; // taken from gui
String password = ... ; // taken from gui

if ((username.equals("hard code value"))&&(password .equals("hard code value"))) {
 // SUCCESS
}

I would like to add that If you don't want to use a database then this:

2 basic arrays, a 2-D array

would be not a good idea.

Create an object User with attributes username, password and an equals method. Then have a list of those objects somewhere stored and when the user logs in create a User object with those values and search the list.

This article has been dead for over six months. Start a new discussion instead.