title: Convert List<Object> to List<CustomClass>
body: <p>I am returning a <code>List</code> of objects with just the type <code>Object</code>. However I know that these objects are of class <code>CustomClass</code> in this case.</p>
  
  <p>When I attempt to cast the original list to the <code>CustomClass</code> I get an error.</p>
  
  <p>This is how I'm working around it currently and it works but I don't like the fact I have a <code>for loop</code> just to do this.</p>
  
  <pre><code>List&lt;Object&gt; objects = getObjects();
  List&lt;CustomClass&gt; customObjects = new ArrayList&lt;&gt;();
          for ( Object object : objects ) {
              if ( object instanceof CustomClass )
                  customObjects.add( (CustomClass) object );
          }
  </code></pre>
  
  <p>Any ideas?</p>