title: Java - Easiest way to get single property from each object in a list/array?
body: <p>Say I have a person object with properties such as <code>name</code>, <code>hair color</code>, and <code>eye color</code>. I have the following array <code>Person[] people</code> that contains instances of person objects.</p>
  
  <p>I know I can get the <code>name</code> property of one the <code>Person</code> objects with </p>
  
  <pre><code>// create a new instance of Person
  Person george = new Person('george','brown','blue');
  // &lt;&lt;&lt; make a people array that contains the george instance here... &gt;&gt;&gt;
  // access the name property
  String georgesName = people[0].name;
  </code></pre>
  
  <p>But what if I want to access the <code>name</code> property of everyone without using indexes? For example, to create an array or list of just names or hair color? Do I have to manually iterate through my <code>people</code> array? Or is there something cool in Java like <code>String[] peopleNames = people.name</code>?</p>