NavigableSet addAll() method in Java
The java.util.NavigableSet.addAll(Collection C) method is used to append all of the elements from the mentioned collection to the existing NavigableSet. The elements are added randomly without following any specific order.
Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course.
boolean addAll(Collection C)
Parameters: The parameter C is a collection of any type that is to be added to the NavigableSet.
Return Value: The method returns true if it successfully appends the elements of the collection C to this NavigableSet otherwise it returns False.
Note: The addAll() method of NavigableSet interface in Java is inherited from the Set interface.
Below programs illustrate the Java.util.NavigableSet.addAll() method:
Program 1 : Appending a tree NavigableSet.
NavigableSet: [4, Geeks, To, TreeNavigableSet, Welcome] NavigableSet: [4, Geeks, Hello, To, TreeNavigableSet, Welcome, World]
Program 2 : Appending an ArrayList.
Initial NavigableSet: [4, Geeks, NavigableSet, To, Welcome] Final NavigableSet: [4, A, Computer, Geeks, NavigableSet, Portal, To, Welcome]