Question

This code:

intersectionMap.size() + "" + intersectionMap.isEmpty()

Returns

9true

Any thoughts? I cant think of any reason this would occur.. Im using the SortedMap type provided by Java as seen here SortedMap (group decision, I'm not familiar with the type).

intersectionMap is obtained from a group of objects that are the result of parsing some map data (xml).

Maybe some of the gurus know whats happening?

Was it helpful?

Solution

SortedMap is an interface. We need to know the actual implementation being used. It's possible that you don't create the implementation yourself, then you have to see it in debug or read library's documentation.

In my project I can see about 40 different implementations of SortedMap interface, so we hardly can guess which one is used in your application.

If inherited from AbstractMap and both methods are not overridden, it's pretty much guaranteed to work properly. That's the original implementation:

public boolean isEmpty() {
return size() == 0;
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top