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 without having to iterate over the list, if it is at all possible?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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.