Java, searching within a list of objects?

Posted by Rick on Stack Overflow See other posts from Stack Overflow or by Rick
Published on 2011-03-03T23:22:45Z Indexed on 2011/03/03 23:24 UTC
Read the original article Hit count: 190

Filed under:
|
|
|

I'm a bit lost on the way to make this happen the fastest. I have a large list of objects that have basic variable attributes (with getters / setters) and I need to do a search in this list to find the objects within the list that match a given parameter

I have found how to do a regular list search but I need to, for example search for the value of the result of doing a call getName() for each object in the list and get objects that have a result that matches my input.

Something like below where the third argument is the result of the method call and the second is what I am trying to find.

   int index = Collections.binarySearch(myList, "value", getName());

Any advice is appreciated

© Stack Overflow or respective owner

Related posts about java

Related posts about list