| Author |
Help placing user input passwords to a array and to then display
|
Leanie Bez
Greenhorn
Joined: Jan 08, 2012
Posts: 2
|
|
I've been asked to create a program where I make up 3 passwords for users. That's not the problem and I'm able to do that. My actual problem is the part where we must take these 3 designed passwords and place them inside a String array and then get it to loop through this array and display out the 3 different passwords. I really don't know how to go about from here and have been stuck on this. PLEASE HELP!
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32644
|
|
Welcome to the Ranch
I have added code tags, removed most of the empty lines and coloured text from your post; those changes make it much easier to read.
Have you been told specifically to put those passwords into an array? That doesn’t sound like object-oriented programming to me. I would have had a User[] array with the password as a field of the User class.
You can read about arrays in the Java tutorials. I would suggest your array needs to be created outside the loop. On the first iteration, you put the details in for the first user, etc etc. Remember the first place in an array has the index shown as [0]. You may do well to remind yourself about the for loop, which you will also find in the Java™ Tutorials. You should not write literal numbers in the for loop, but use the length field
Should display 0 2 4 6 8 etc.
|
 |
Leanie Bez
Greenhorn
Joined: Jan 08, 2012
Posts: 2
|
|
Thank you so much for the fast reply and for helping me make my code look much easier to read. Apologies for that and in the future I'll make it more easier to read. I read everything you said and did check out the tutorials but I'm still completely stuck. I have no idea how to tell the computer to work with the specific 3 passwords that have been created from the user. I've tried several methods but it never works out. Placing them into a array is then my other problem
|
 |
 |
|
|
subject: Help placing user input passwords to a array and to then display
|
|
|