how to save strings that user put into an array? JAVA | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

how to save strings that user put into an array? JAVA

https://code.sololearn.com/cbJNq1Vcrzmg This is pretty long code I need help that making a loop that user put the information and save that into an array I made how many they want and how to display but I don't know how to save the information... any help is great! Thank you, guys! I tried to do this but it doesn't work for (int i = 0; i < leg.length; i++) { fname = prompt_first_name(); lname = prompt_last_name(); nname = prompt_nickname(); role = prompt_role(); origin = prompt_origin(); }

11th Jun 2017, 6:52 PM
Kurt Cobain
Kurt Cobain - avatar
7 Answers
+ 2
Here is your code fixed. There were a few problems: 1) When the user entered a number the number would create a certain amount of Legends in the Leg array. But when it was populated the program would try to populate exactly 10 spaces, so I added a for loop to populate every position in Leg. 2) Brackets were missing. So I fixed those. 3) You tried to print a method that prints results. So I added a toString() function to return the wanted string. 4) I struggled to understand why you didn't use certain methods. But I ignored it in the end. But it really slowed me down. https://code.sololearn.com/cXgRd0l6ZgoG/?ref=app I hope this helps you!
11th Jun 2017, 8:17 PM
Limitless
Limitless - avatar
+ 2
Like press "Enter" on your keyboard. That will go to the next line. That next line is seen as your second input as Kurt mentioned
11th Jun 2017, 7:23 PM
Limitless
Limitless - avatar
+ 2
Thanks will quickly fix that [Fixed]
11th Jun 2017, 8:21 PM
Limitless
Limitless - avatar
+ 1
In that case I remove my answers and apologies for the spam and unwanted rumours
11th Jun 2017, 7:04 PM
Limitless
Limitless - avatar
+ 1
This is one of the best apps I recommend to all
11th Jun 2017, 7:04 PM
Limitless
Limitless - avatar
+ 1
how do I break the line for multiple inputs? I don't understand...
11th Jun 2017, 7:11 PM
Kurt Cobain
Kurt Cobain - avatar
+ 1
Thanks guy. I appreciate! but how I can write the code though? what are errors in my code could you tell me?
11th Jun 2017, 7:46 PM
Kurt Cobain
Kurt Cobain - avatar