• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Array list help.

 
Frank Espinoza
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need to prompt a user to enter his name and then address the user by name, afterwards I need to prompt for 20 more names and then stored the names as an array list. I can get the first part but I'm not sure how to prompt for the other names and save them.. I would greatly appreciate any advice.
 
Rob Spoor
Sheriff
Pie
Posts: 20665
65
Chrome Eclipse IDE Java Windows
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you show us the loop you've written?
 
Nico Van Brandt
Ranch Hand
Posts: 70
IntelliJ IDE Java Mac
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just push the names in the arraylist?

Pseudo code:

Initialize ArrayList
Prompt username
Display Hello, username!

Loop 20 times
Prompt for username
ArrayList.Add(username) // Somewhat less pseudo-ish ;)
End Loop
 
Frank Espinoza
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm sorry about the late response, but this is what I have so far:
<body>
<script type="text/javascript">
var name=prompt("Please Enter Name");
alert("hello" + name);
document.write(name.length);
document.write(word.touppercase ());
</script?


 
Nico Van Brandt
Ranch Hand
Posts: 70
IntelliJ IDE Java Mac
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hmm yeah..
that's not Java but Javascript
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15482
43
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JavaScript is something totally different than Java. They have similar names only because of an unfortunate historical accident...

Java's ArrayList doesn't exist in JavaScript.

So, do you want to do this in JavaScript or in Java?
 
Nico Van Brandt
Ranch Hand
Posts: 70
IntelliJ IDE Java Mac
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic