I'm writing a piece of code which takes a great deal of objects and adds them to another array. The catch is, I don't want any duplicates. Is there a way I could implement a Hashset to solve this problem?
    public static Statistic[] combineStatistics(Statistic[] rptData, Statistic[] dbsData) {
    HashSet<Statistic> set = new HashSet<Statistic>();
    for (int i=0; i<rptData.length; i++) {
        set.add(rptData[i]);
    }
    /*If there's no data in the database, we don't have anything to add to the new array*/
    if (dbsData!=null) {
        for (int j=0; j<dbsData.length;j++) {
            set.add(dbsData[j]);
        }
    }
    Statistic[] total=set.toArray(new Statistic[0]);
    for (int workDummy=0; workDummy<total.length; workDummy++) {
        System.out.println(total[workDummy].serialName);
    }
    return total;
}//end combineStatistics()
 
     
     
    