title: Pass An ArrayList<CustomObject> to a function that accepts as parameter an ArrayList<Object> in Java
body: <p>I am writing a generic java-android function that will accept as one of it's parameters an <code>ArrayList&lt;Object&gt;</code>, so that I can use all over my application regardless of the type of the ArrayList elements.</p>
  
  <p>This is my function:</p>
  
  <pre><code>public GenericDisplayAdapter(Activity activity, ArrayList&lt;Object&gt; arrData) {
  
      this.m_ArrData = arrData;
      inflater = (LayoutInflater) activity
              .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
  }
  </code></pre>
  
  <p>When I try to to pass my <code>ArrayList&lt;CustomObject&gt;</code> as a parameter to this function, I get the error "can't cast from <code>ArrayList&lt;CustomObject&gt;</code> to <code>ArrayList&lt;Object&gt;</code>", </p>
  
  <pre><code>        m_LVStructDamageHeader.setAdapter(new GenericDisplayAdapter(
              (Activity)this, (ArrayList&lt;Object&gt;)arrStructDamageHeaders));
  </code></pre>
  
  <p>What is the best approach to handle such a situation, Thanks </p>