trupti nigam wrote:HI,
I have below code
if(_theCache.containsKey(new Long(currentItem)))
{
_theCache.remove(currentItem);
}
I am debugging the above code. Looks like even if the key is there in _theCache, it's not getting removed. _theCache shows same size even after it goes through _theCache.remove(currentItem);
line of code.
How does the Map remove works? why it doesn't seem to work in above case.
thanks
Trupti
Hard to say what the problem is with just this code, but here is my train of thought:
You are trying to remove the key differently than you are checking if it contains the key, which is the proper method for converting currentItem to the proper key value? What data type is currentItem? What type is used for the keys in the map? How do you know it is the remove() that isn't working, and not the containsKey()?
For a description of how .remove() works,
read the API here .