Removing multiple entries from ArrayList in Java by date -
so have arraylist called inpeople, has class stored in named peoplein. data stored in class
peoplein( int scannernum, date date, int empnum){
so basically, program system reads through logs of punch clock find out who's in building. problem is, if person punches in number of times, never punches out, end duplicates in list. basically, need keep recent punch in.
can done?
you can use map<key,value>
, if put value same key
. previous value replace current value.
eg:
map<string,string> map=new hashmap<>(); map.put("emp1", "val1"); map.put("emp2","val2"); system.out.println(map); // putting emp1, val3 map.put("emp1","val3"); system.out.println(map);
out put:
{emp2=val2, emp1=val1} {emp2=val2, emp1=val3}
Comments
Post a Comment