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(); }
12 odpowiedzi
+ 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!
+ 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
+ 2
Thanks will quickly fix that
[Fixed]
+ 1
In that case I remove my answers and apologies for the spam and unwanted rumours
+ 1
This is one of the best apps I recommend to all
+ 1
how do I break the line for multiple inputs?
I don't understand...
+ 1
Thanks guy. I appreciate! but how I can write the code though?
what are errors in my code could you tell me?