• Post Reply Bookmark Topic Watch Topic
  • New Topic

Generics and a copy method  RSS feed

 
vuthlarhi donald
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have written this code and I want to add a method called copy that copies into a destination list of all the elements of the source list...your help will be appreciated


 
Peter Chase
Ranch Hand
Posts: 1970
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Seems unnecessary.

Arrays.asList() will make a List that reflects an array.

Collection.addAll() will add all items of one Collection to another.

Collections.addAll() will add a variable argument list, or the elements of an array, to a Collection.

Note that Collection and Collections are different classes.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!