Duplicata possible : Trouver efficacement l'intersection d'un nombre variable d'ensembles de chaînes
Dites, avez deux Hashset, comment calculer leur intersection ?
Set<String> s1 = new HashSet<String>(); Set<String> s2 = new HashSet<String>(); S1 INT S2 ?
Réponse
Trop de publicités?
Emmanuel N
Points
4090
Oui, il y a retainAll
vérifier ceci
Set<Type> intersection = new HashSet<Type>(s1);
intersection.retainAll(s2);