javarevisited |
Union and Intersection of two Set in Java - Google Guava Example Posted: 10 Dec 2012 04:50 AM PST Google Guava is an open source library which provides lots of useful utility to Java programmer, one of them is easy way to find intersection and union of two Set in Java. You might have used Google Guava for other functionality e.g. for overriding toString in easy way or Immutable Collection provided by Guava library. Along with Apache commons and Spring, Google Guava is a library you definitely want to include in your Project. Guava provides couple of static method to operate on Set in Java on package com.google.common.collect.Sets. There are two methods called intersection() and union() which provides intersection and union of two Sets in Java. In this example we have used HashSet as Set implementation but it will work with any Set implementation e.g. TreeSet or LinkedHashSet. |
You are subscribed to email updates from Javarevisited To stop receiving these emails, you may unsubscribe now. | Email delivery powered by Google |
Google Inc., 20 West Kinzie, Chicago IL USA 60610 |
Post a Comment