I've an ArrayList, for example b, and i want to get an ArrayList of Worker (Worker extend Person) from that ArrayList. b also contains other object that extends from Person.
How can i achive that? Thanks.
If you use Guava, it is as easy as:
ArrayList<Person> b;
ArrayList<Worker> a = Lists.newArrayList(Iterables.filter(b, Worker.class));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With