I have an ArrayList of objects. The objects are all of the same class and contain a public field that is a boolean data type. Is it possible to determine if any instances within the arraylist exist where this field is set to true without having to iterate through the entire array and checking each field? Just wondering whether there is a shorthand version of an iteration loop. Thank you.
Share
Kind of…
You’re looking for something like LINQ for Java, so you can do something similar to
collection.any(x => x.bool)Here are some libraries:
What is the Java equivalent for LINQ?
If you look through them you should find some short hand functions to do that, but all of them iterate through the collection somehow (just hidden beneath a function).