Java TreeSet addAll() MethodThe addAll() method of TreeSet class is used to add elements of one set to another set. Syntax:Parameter:c- elements to be add to the set. Return:It returns true if set is changed else it returns false Example 1Output: TreeSet: [7, 10, 13, 20] [1, 3, 6, 9] true TreeSet after adding: [1, 3, 6, 7, 9, 10, 13, 20] Example 2Output: TreeSet: [ 1, 2, 5, 8, 10 ] false TreeSet: [ 1, 2, 5, 8, 10 ] Example 3Output: TreeSet: [ A, B, a, b ] [ 1, 3, 6, 9 ] true TreeSet: [ 1, 3, 6, 9, A, B, a, b ] Next TopicJava-treeset-add-method |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India