So right now I'm writing a program that will take a user input such as:
- "Jeff" for a first name
- "Henderson" for a last name
- a phone number with them
- an amount to be stored in their bank account
And store it all into a Linked List.
If I were to add another person with this similar info, how would that be stored in the link list such at I could access both individuals information separately?
Right now I'm using this to establish all the storage when entering a new user:
private final Scanner keyboard;
private final LinkedList<String> firstName;
private final LinkedList<String> lastName;
private final LinkedList<String> teleNumber;
private final LinkedList<String> accountBalance;
public bankdata()
{
this.keyboard = new Scanner(System.in);
this.firstName = new LinkedList<String>();
this.lastName = new LinkedList<String>();
this.teleNumber = new LinkedList<String>();
this.accountBalance = new LinkedList<String>();
}
I plan to use keyboard.next();
to read the user input and then use an add method I've written to store the information into each linked list.
The way it is set up is that there is a Linked List for every single object variable like:
- a Linked List for first name
- a Linked List for the last
- a Linked List for the tele number
- a Linked List for the account balance
If I want to call information associated with one specific person, how do I have it so when I request that users information that I can see all his stuff if they're in another linked list?