Using objects/inherited classes in Linked Lists
<p>Apologies if my terminology is incorrect, I have only started Java (and OO programming in general) 6 weeks ago.</p>

<p>A homework assignment has given me an interface class:</p>

<pre><code>public interface Example {
    void Function();
    //etc
}
</code></pre>

<p>And then I have a couple of classes that "implement" that interface class, eg:</p>

<pre><code>public class myExample1 implements Example {
    void Function(){ stuff;}
    public void myExclusiveFunction() { stuff;}
        ...
}
</code></pre>

<p>Inside the <code>myExample1</code> class, I define the functions inside <code>Example</code>, but also add some specific functions to the <code>myExample1</code> class.</p>

<p>In my main program, I have created a <code>LinkedList&lt;Example&gt; eList = new LinkedList&lt;Example&gt;</code>. Inside that Linked List, I am storing multiple types of Examples (myExample1, myExample2, etc). I want to do something like:</p>

<pre><code>eList.get(i).myExclusiveFunction();
</code></pre>

<p>However this will not work. The compiler tells me:</p>

<blockquote>
  <p>The method myExclusiveFunction() is undefined for the type Example.</p>
</blockquote>

<p>How can I use this function? I really want to have the LinkedList be able to hold objects of any Example subclass, and I am under an assignment restriction to NOT edit the Example interface.</p>
