Java tutorial
//package com.java2s; //License from project: Open Source License import java.util.Iterator; import java.util.Set; public class Main { public static double calcStrSetSimilarity(final Set<String> strASet1, final Set<String> strASet2) { int containsCount = 0; final Iterator<String> iter = strASet2.iterator(); while (iter.hasNext()) { if (strASet1.contains(iter.next())) { containsCount++; } } return (double) containsCount / (double) strASet1.size(); } }