java - creating two dimensional hashset functionality -
i trying make 2 dimensional hashset functionality. have loop iterates through pairs of integers:
resultset getassociations; statement getassociationsselect = sqlconn .createstatement(); getassociations = getassociationsselect .executequery("select productid, themeid producttheme"); while(getassociations.next()) { int productid1 = getassociations.getint(1); int themeid1 = getassociations.getint(2); }
when current pair of integers not match previous pair of integers want store them. figured hashset best approach because can insert pairs , wont take repeats. how do this?
if want simple solution concatenate both keys , store resulting string, e.g.
string newkey = string.format( "%d-%d.", productid1 , themeid1 );
it allways generate unique key each combination.
Comments
Post a Comment