Kiru
Kiru

Reputation: 169

Easy access to entries in set - using where conditions

The class structure is of the following format-

class A
{
   Set<B> bHolder;
}

class B
{
   Set<C> cHolder;
}

class C
{
   String data;
}

Goal : To retrieve an entry from class A depending on the data in class C

Eg: get B from aObject.bHolder.cHolder.data = "compareString"

Is there any way to do it without completely through the sets?

Thx -Kiru

Upvotes: 2

Views: 48

Answers (1)

Jon Skeet
Jon Skeet

Reputation: 1500825

Not when you've just got sets, no. If you want to perform some sort of lookup, you need a collection which supports lookups, such as HashMap (or a Map in general).

Upvotes: 1

Related Questions