Java collection filtering
•
Java
I have such things:
public class Foo { public String id; }
and
Vector<Foo> foos;
I need to get an object from the collection by ID
In C #, I would do this: foos Where(o => o.id = 7)
What is the best way in Java?
Solution
You may want to store data in map < integer, foo > Instead of list < foo > For example, a treemap saves everything in sorted order
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码