Java tutorial
//package com.java2s; import java.util.*; public class Main { public static double computeDice(Collection<String> c1, Collection<String> c2) { Set<String> intersection = new HashSet<>(c1); 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; } }