Reputation: 181
I'm reviewing for a class, and this is an old question:
I need to write a method
void addAll(Collection c1, Collection c2);
that adds all the elements in c2 to c1.
Could I just do something with addAll? I'm not familiar with it, but it seems like I could write:
c1.addAll(c2);
Upvotes: 1
Views: 7906
Reputation: 74800
If your task is to write such a method, it may be the case that you are not allowed to use the addAll
method (since it would be too easy, and you learn not so much). If so, think about how to write it again (read the documentation linked by kubi for inspirations).
Upvotes: 0
Reputation: 313
Yes, that'll work. The boolean returned determines whether the collection has been modified by the call.
http://download.oracle.com/javase/6/docs/api/java/util/Collection.html#addAll(java.util.Collection)
Upvotes: 3