title: Working on the properties of the objects in a list?
body: <p>Given the following Code:</p>
  
  <pre><code>public class MyObject { 
  
  String myProperty;
  
  public MyObject(String propertyValue) {
      myProperty=propertyValue; 
  }
  }
  </code></pre>
  
  <p>and</p>
  
  <pre><code>public class Main {
  
  public static void main(String[] args) {
  
      ArrayList&lt;MyObject&gt; objects = new ArrayList&lt;MyObject&gt;();
      objects.add(new MyObject("first"));
      objects.add(new MyObject("second"));
      objects.add(new MyObject("third"));
  
      // Now do Task A and Task B
  }
  }
  </code></pre>
  
  <p>Now I am looking for the best way to do the following:</p>
  
  <p><strong>Task A: Find all objects where myProperty equals "second".</strong> 
  Is there something like </p>
  
  <pre><code>ArrayList&lt;MyObject&gt; filteredObjects = objects.findPropertyValue(myProperty, "second") ?
  </code></pre>
  
  <p><strong>Task B: Extract the different myProperty values from the list, meaning I want to get an array which includes ("first","second","third")</strong>
  Is there something like </p>
  
  <pre><code>ArrayList propertyValues = objects.getPropertyValues(myProperty) ?
  </code></pre>
  
  <p>I know that Task A and B can be solved by looping through the ArrayList, but I am wondering if there is a better way / already something built-in in Eclipse? Thanks for any hint :-)</p>
  
  <p>Please note I do not want to use external libraries (I am currently developing on android and want to keep my application small).</p>