VOOZH about

URL: https://www.geeksforgeeks.org/java/list-addall-method-in-java-with-examples/

⇱ List addAll() Method in Java with Examples - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

List addAll() Method in Java with Examples

Last Updated : 2 Jan, 2019
This method appends all of the elements in the specified collection to the end of this list, in the order that they are returned by the specified collection's iterator. Syntax:
boolean addAll(Collection c)
Parameters: This function has a single parameter, i.e, Collection c, whose elements are to be appended to the list. Returns: It returns true if the elements of specified list is appended and list changes. Below programs show the implementation of this method. Program 1:
Output:
[10, 15, 20]
[100, 200, 300]
[10, 15, 20, 100, 200, 300]
Program 2: Below is the code to show implementation of list.addAll() using Linkedlist.
Output:
[10, 15, 20]
[100, 200, 300]
[10, 15, 20, 100, 200, 300]
Reference: Oracle Docs
Comment