Originally posted by Akhil Vadekk:
Here temp is used again in the iteration. If i dont use clear() function, then all the previous key/value pairs will be maintained in temp.
No, the values are all lost because you are declaring the local variable anew.