Say I have
List<SomeObject> objList = new ArrayList<SomeObject>();
If SomeObject contains a field named id. Can we find it through some query like
objList.filter('id=2');
without looping through the list? If not, then why? This can be such a useful method and can be used as an alternative to write a tedious for loop.
If you want something like linq for java, check out quaere
Edit: At this point, quaere looks like it is unmaintained. With Java 7 being EOL, you should be on Java 8 whose Stream API should get you most of the way there when compared to Linq’s dot syntax. See this page for some examples.