Java: Finding objects in collections.

Posted by Jake on Stack Overflow See other posts from Stack Overflow or by Jake
Published on 2009-02-25T19:15:27Z Indexed on 2010/05/06 12:18 UTC
Read the original article Hit count: 275

Filed under:
|

This problem occurs over and over. I have some complicated object, such as a Cat, which has many properties, such as age, favorite cat food, and so forth.

A bunch of Cats are stored in a Java Collection, and I need to find all the Cats that are aged 3, or those whose favorite cat food is Whiskas. Surely, I can write a custom method that finds those Cats with a specific property, but this gets cumbersome with many properties; is there some generic way of doing this?

© Stack Overflow or respective owner

Related posts about java

Related posts about collections