Search code examples
javadictionarycollectionshashmaptreemap

Howto check if a TreeMap contains a specific object?


In an application I have this TreeMap object:

treePath = new TreeMap<String, DLFolder>();

The first String parameter should be the key and the DLFolder is the value.

Ok the DLFolder object have this method dlFolder.getPath() that return a String

So I want to know if the treePath object contains a DLFolder object having a specific path value

Can I do this thing?

Tnx


Solution

  • for (DLFolder dlf : treePath.values()) {
    if ("A SPECIFIC PATH".equals(dlf.getPath()) {
    // do someting with the dlf
    }