In the javadocs, a FindDups2 class is outlined that will remove duplicates from a set. I copied that code into IntelliJ but now I'm not sure what to call it on. I have created an arrayList in another class in the same folder and tried calling FindDups2 in my arrayList class and tried using the arrayList in the FindDups2 class.
I'm confused because I would know how to call it if it were a method, but I'm not sure how to call a class (FindDups2) on an instance of a class (allFriends) in another class (arrayList). I'm also confused since this the FindDups class doesn't have a constructor. My intuition would be to instantiate my array list instance (allFriends) as an instance variable in the FindDups class and then call it in the findDups class.
PS - this is my first time posting on stackOverflow and I'm a newbie to programming so please be kind and let me know if I'm missing any community norms!
Here's the code I have from the javadocs:
import java.util.*;
/**
* This program removes all duplicate items in a set
* & prints out which words were unique & which were dups.
*/
public class FindDups {
public arrayList allFriends;
public static void main(String[] args) {
Set<String> uniques = new HashSet<String>();
Set<String> dups = new HashSet<String>();
for (String a : args)
if (!uniques.add(a))
dups.add(a);
// Destructive set-difference
uniques.removeAll(dups);
System.out.println("Unique words: " + uniques);
System.out.println("Duplicate words: " + dups);
}
}