Doesn't return occurrences
<p>I can't figure out how to get occurrences to work, it just outputs 0's.
The output should look like this:</p>

<p>List: 2 1 0 1 0 1 4 3 4 2 4 3 3 0 0 4 0 1 3 2
Occurrences of 0: 5
Occurrences of 1: 4
Occurrences of 2: 3
Occurrences of 3: 4
Occurrences of 4: 4</p>

<pre><code>public class PEX6
 {
    private static int CountValue
    (ListInterface&lt;Integer&gt; theList, int theValue)
    {
        theList.reset();
        int nFound = 0;

        for (int i=0; i&lt;=19; i++)
        {
            theList.getNext();
            if (theList.equals(theValue))
            {
                nFound++;
            }
        }
        return nFound;
    }

    public static void main(String[] args)
    {

        ListInterface&lt;Integer&gt; theList = new RefList&lt;Integer&gt;();

        for (int i = 0; i &lt;= 19; i++)
        {
            int Random = ((int)(Math.random()*4));
                theList.add(new Integer(Random));
        }

                theList.writeLinkedList();
                theList.toString();



        int [] valueCount = new int[5];
            for (int i = 0; i &lt; 4; i++)
            {
                valueCount[i] = CountValue(theList, i);
            }

            System.out.println("Occurrences of 0:"+ valueCount[0]);
            System.out.println("Occurrences of 1:"+ valueCount[1]);
            System.out.println("Occurrences of 2:"+ valueCount[2]);
            System.out.println("Occurrences of 3:"+ valueCount[3]);
            System.out.println("Occurrences of 4:"+ valueCount[4]);

    }

 }
</code></pre>

<p>Main file implements these two files:</p>

<pre><code>class LLObjectNode&lt;T&gt;
 {
    private LLObjectNode&lt;T&gt; link;
    private T info;

    public LLObjectNode ( T theInfo )
    {
        info = theInfo;
        link = null;
    }

    public void setInfo ( T theInfo )
    {
        info = theInfo;
    }

    public T getInfo()
    {
        return info;
    }

    public void setLink ( LLObjectNode&lt;T&gt; theLink )
    {
        link = theLink;
    }

    public LLObjectNode&lt;T&gt; getLink()
    {
        return link;
    }

 }

 // Stores and manipulates collection of objects in accordance with ListInterface functionality:

 public class RefList&lt;T&gt; implements ListInterface&lt;T&gt;
 {
    // Stores number of elements within list:

    protected int numElements;

    /*
     * Points to first node of list:
     *
     * This variable will be set to null, when list is empty.
     */

     protected LLObjectNode&lt;T&gt; first;

     /*
      * Used for iteration through list:
      *
      * This variable will be set to null until call is made to reset() method,
      * at which this variable will point to first element of list:
      */

      protected LLObjectNode&lt;T&gt; currentPos;

      // Used to locate elements on list:

      // Set to true if find (...) is successful:
      protected boolean found;

      // Points to the found element:
      protected LLObjectNode&lt;T&gt; location;

      // Points to element preceding the found element:
      protected LLObjectNode&lt;T&gt; previous;

      /*
       * Attempts to find element contained within list that exists as a copy
       * of the given object:
       *
       * If find is successful, the found variable will be set to true, the location
       * variable will point to found element, and the previous variable will point to the
       * element preceding the found element, unless the found element is the first element of list.
       */

       protected void find ( T theTarget )
       {
            found = false;
            location = first;
            previous = null;

            while ( location != null )
            {
                if ( location.getInfo().equals( theTarget ))
                {
                    found = true;
                    break;
                }

                else
                {
                    previous = location;
                    location = location.getLink();
                }
            }
        }

        // Creates empty list:

        public RefList()
        {
            currentPos = null;
            first = null;
            numElements = 0;
        }

        // Returns number of elements within list:

        public int size()
        {
            return numElements;
        }

        // Returns true if this list contains copy of given object:

        public boolean contains ( T theTarget )
        {
            find( theTarget );
            return found;
        }

        // Removes first element found in list that exists as copy of given
        // object and returns true  if such element was found:

        public boolean remove ( T theTarget )
        {
            find( theTarget );

            if ( found )
            {
                if ( location == first )
                    first = first.getLink();
                else
                    previous.setLink( location.getLink());

                --numElements;
            }

        return found;
        }

    // Returns reference to first element found within list that exists as copy
    // of given object or null if no such element was found:

    public T get ( T theTarget )
    {
        find( theTarget );

        if ( found )
            return location.getInfo();
        else
            return null;
    }

    // Returns a nicely formatted string representation fo this list:

    public String toString()
    {
        LLObjectNode node = first;
        StringBuffer buff = new StringBuffer ( "List:" );

        while ( node != null )
        {
            buff.append( " " + node.getInfo());
            node = node.getLink();
        }

        return buff.toString();
    }

    // Prints contents of this list to screen:

    public void writeLinkedList()
    {
        System.out.println( toString());
    }

    // Initializes this list for iteration:

    public void reset()
    {
        currentPos = first;
    }

    /*
     * Returns reference to element located at currentPos and increments currentPos
     * to point to next element contained within list:
     *
     * If correntPos is pointing to last element in list, it will be reset to point to
     * first element in list.
     *
     * @Preconditions:
     *      This list is not empty.
     *      This list has been reset.
     *      This list has not been modified since last reset.
     */

     public T getNext()
     {
        T next = currentPos.getInfo();

        if ( currentPos.getLink()== null )
            currentPos = first;
        else
            currentPos = currentPos.getLink();

        return next;
     }

     // Inserts given object onto front of list:

     public void add ( T theObject )
     {
        LLObjectNode&lt;T&gt; node = new LLObjectNode&lt;T&gt; ( theObject);

        node.setLink( first );
        first = node;
        ++numElements;
     }
 }


public interface ListInterface&lt;T&gt;
{
    // Returns number of elements within list:

    int size();

    /* Returns tru if list contains a copy of given object:
     *
     * Comparisons should be performed by calling the equals(...) method of
     * each element, passing the given object as an argument
     */

    boolean contains ( T theObject);

    /*
     * Removes the first element found within this list that exists as a copy of
     * the given object and returns true if element was found:
     */

    boolean remove ( T theObject);

    /*
     * Returns reference to first element found within this list that exists as a
     * copy of the given object or null if no such element was found:
     */

    Object get ( T element);

    // Returns a nicely formatted string representation of this list:

    String toString();

    // Prints the contents of this list to screen:

    void writeLinkedList();

    // Initializes this list for iteration (use of the getNext() method):

    void reset();

    /*
     * Returns reference to the element located at the iterator's current
     * position and increment the iterator:
     *
     * If iterator is currently pointing to the last element in this list,
     * the iterator should be reset to point to first element in list.
     *
     * @Preconditions:
     *      This list is not empty.
     *      This list has been reset.
     *      This list has not been modified since last reset.
     */

     T getNext();

     // Inserts the given object onto front of list:

     void add ( T theObject);
}
</code></pre>
