• Post Reply Bookmark Topic Watch Topic
  • New Topic

List to ArrayList  RSS feed

 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Any quick painless way to get objects from a java.util.List put into an ArrayList without manually looping over all the objects in the List?
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just "new ArrayList(theList)" works.
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ernest Friedman-Hill:
Just "new ArrayList(theList)" works.




Thanks.
 
David Harkness
Ranch Hand
Posts: 1646
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just to be pedantic, ArrayList's constructor merely loops over the original List itself, in case you were hoping to save the runtime time cost -- not save typing time.

It works wonders for the latter, however.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!