Here you can find the source of compareSet(Set set1, Set set2)
public static int compareSet(Set set1, Set set2)
//package com.java2s; /**// w ww.j a v a 2s . c o m * Copyright (c) 2005-2009 springside.org.cn * * Licensed under the Apache License, Version 2.0 (the "License"); * * $Id: ReflectionUtils.java,v 1.1 2014/11/10 06:38:51 daiyl Exp $ */ import java.util.*; public class Main { public static int compareSet(Set set1, Set set2) { int sameCount = 0; for (Object o : set1) { if (set2.contains(o)) sameCount++; } return sameCount; } }