Java tutorial
//package com.java2s; import java.util.*; public class Main { public static double computeFrequencyWeightedDice(Collection<String> c1, Collection<String> c2) { List<String> union = new ArrayList<>(); union.addAll(c1); union.addAll(c2); List<String> intersection = new ArrayList<>(union); intersection.retainAll(c1); intersection.retainAll(c2); if (intersection.size() == 0) return 0.0; double score = 2 * (double) intersection.size() / (c1.size() + c2.size()); return score; } }