mardi 4 août 2015

Using Hashmap contains to check for a duplicate key

So i have an interface.

    public interface ARecord {
        public BigInteger getAutoID();
        public String getACompId();
}

and

    public class APPPRecord extends AbstratAPRecord implements ARecord{
    private BigInteger autoID;
    private String ACompId = null;
   //setter and getter}

In service,

    List<APPPRecord> PFRecord = null;
    while(scroll.next()){
    APPPRecord item = (APPPRecord) scroll.get(0);
    List<ARecord> recs = new ArrayList<ARecord>();
    recs.addAll(PFRecord);

My PFRecord list has results that are being duplicated. I have to use hash maps that can check for ACompId contains key. If the key already exists don't pass it to recs.addAll. How can I go about doing this? Any help appreciated



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire