Java LinkedList with Object
<p>Trying to implement a LinkedList that simulates a Portfolio, consisting of Stock objects. I'm struggling to figure out how to properly iterate through the list and check if each stock contains certain parameters. the SHAREPRICE method is the one I'm having trouble with specifically, if someone could help with that, I'd be very grateful. What I have so far:</p>

<pre><code>import java.util.*;

public class Portfolio&lt;AnyType&gt; implements Iterable&lt;AnyType&gt; {

public int balance, shares;
private Stock&lt;AnyType&gt; beginMarker, endMarker, temp;

LinkedList&lt;Stock&gt; Portfolio = new LinkedList&lt;Stock&gt;();
java.util.Iterator&lt;Stock&gt; iter = Portfolio.iterator();

public int CASHIN(int x) {
    balance = x;
    return balance;
}

public int CASHOUT(int y) {
    balance = balance + (-y);
    return balance;
}

public int CASHBALANCE() {
    return balance;
}

public void BUY(String t, int s, float pp) {
    temp = new Stock&lt;AnyType&gt;(t, s, pp, pp, 0, null, null);
    Portfolio.add(temp);
    shares = shares + s;
}

public void SELL(String t, int s, float pp) {
    shares = shares - s;
}

public void SHAREPRICE(String t, float pp)
{
    if(Portfolio.contains(Stock.)
    {

    }


}

public void QUERY(String t) {

}

public int COUNTPORTFOLIO() {
    return shares;
}

public void PRINTPORTFOLIO() {

}

public java.util.Iterator&lt;AnyType&gt; iterator() {
    return new Iterator();
}

private class Iterator implements java.util.Iterator&lt;AnyType&gt; {
    private Stock&lt;AnyType&gt; current = beginMarker.next;
    private boolean okToRemove = false;

    public boolean hasNext() {
        return current != endMarker;
    }

    public AnyType next() {
        if (!hasNext())
            throw new java.util.NoSuchElementException();

        AnyType nextItem = (AnyType) current.getTicker();
        current = current.next;
        okToRemove = true;
        return nextItem;
    }

    public void remove() {
        if (!okToRemove)
            throw new IllegalStateException();

        Portfolio.this.remove(current.prev);
        okToRemove = false;
    }
}

private class Stock&lt;AnyType&gt; implements Comparable&lt;Stock&lt;AnyType&gt;&gt; {

    public String getTicker() {
        return ticker;
    }

    public void setTicker(String ticker) {
        this.ticker = ticker;
    }

    public float getPurchasePrice() {
        return purchasePrice;
    }

    public void setPurchasePrice(float purchasePrice) {
        this.purchasePrice = purchasePrice;
    }

    public float getLatestPrice() {
        return latestPrice;
    }

    public void setLatestPrice(float latestPrice) {
        this.latestPrice = latestPrice;
    }

    public float getPctChange() {
        return pctChange;
    }

    String ticker;
    int sharesOwned;
    float purchasePrice, latestPrice;
    float pctChange = (latestPrice - purchasePrice) / purchasePrice;
    Stock&lt;AnyType&gt; prev, next;

    public Stock(String ticker, int sharesOwned, float purchasePrice,
            float latestPrice, float pctChange, Stock&lt;AnyType&gt; prev,
            Stock&lt;AnyType&gt; next) {
        this.ticker = ticker;
        this.sharesOwned = sharesOwned;
        this.purchasePrice = purchasePrice;
        this.latestPrice = latestPrice;
        this.pctChange = pctChange;
        this.prev = prev;
        this.next = next;
    }

    public int compareTo(Stock&lt;AnyType&gt; pctChange) {
        return ((Comparable) this.pctChange)
                .compareTo(Stock.getPctChange());

    }

}

}

class TestPortfolio {
public static void main(String[] args) {

}
}
</code></pre>
