16.7.5 Methods addAll, frequency and disjoint

Class Collections also provides the methods addAll, frequency and disjoint. Collections method addAll takes two arguments—a Collection into which to insert the new element(s) and an array that provides elements to be inserted. Collections method frequency takes two arguments—a Collection to be searched and an Object to be searched for in the collection. Method frequency returns the number of times that the second argument appears in the collection. Collections method disjoint takes two Collections and returns true if they have no elements in common. Figure 16.13 demonstrates the use of methods addAll, frequency and disjoint.

 1   // Fig. Fig. 16.13: Algorithms2.java ...

Get Java™ How To Program (Early Objects), Tenth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.