Say I have an list of objects with two fields field1
and field2
, both of String type.
How do I get a list of all field1
values wit
An object is a reference towards a memory address. Then, the fields of this objects are other references towards other memory addresses. Hence, a list of objects is a list of references. So, it's impossible for the list to direclty access the object fields (references given by the references). The short answer is no.
Note: anyway you'll find an API that does what you want, it still loops in the inside.