This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ArrayList Use Question

 
G. Graz
Ranch Hand
Posts: 30
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to populate an ArrayList using user input. Each input I thought should register as it's own index in the ArrayList ? Problem I am having is my ArrayList is only holding the current value that was entered, should I have some type of loop that will add the elements to the array ? and/or am I using the ArrayList in the wrong way ? Thank you !

 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64192
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're creating a new list each time.
 
Kumaresh Vidhyasagar
Ranch Hand
Posts: 30
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just create the instance of the arraylist before the while loop. It will work
 
G. Graz
Ranch Hand
Posts: 30
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bingo !!! So simple and I did not even see it ! Thank you again for the extra set of eyes !
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic