i have hashmap :
hashmap<integer, person> map
the key month (int) calendar.month. means goes 0 11 , each month has object of type person associated.
assuming in february, getting person of past 4 months can't find way this. have assume month missing in map in such case consider person of month "0" or null or whatever don't want "skip" it.
can me figure out ? have no idea of "proper" way achieve this.
here steps need do:
get current month calendar instance. month 0 11.
create loop loops 4 times
within loop, person current month map. add person list.
within loop, subtract 1 month current month. if current month less zero, add 12 current month.
your list contain 4 person objects, or null if that's map returned.
Comments
Post a Comment