java - Avoiding duplicate values in the datatable -
i have list of product info in datatable1 , list of selected product info in datatable2 (which user has selected datatable1 , add together dattable2) want perform 1 check if user selected datatable1 add together & if same info exists in list should not added list of datatable 2 friend suggested use
hashmap<string ,list<model>>
is improve approach accomplish functionality ? thanks
if can utilize java.util.set
implementations rather list
, build duplicate-free list of model
follows:
set<model> datatable1 = ... set<model> datatable2 = ... datatable2.addall(datatable1);
datatable2
contain either in datatable1
or datatable2
, no duplicates (set union operation).
be sure implement appropriate equals
, hashcode
on model
class.
java jsf-2 richfaces
No comments:
Post a Comment