Not relying on a number being stored at index. method help
<p>I've been asked to change the 'getlot' method in this class so that it doesn't rely on a lot with a particular number being stores at index [number -1] in the collection. e.g, if lot # 3 was deleted, then lot # 4 would have been changed from index 3 to 2. I've tried recoding but to no avail. Any help is appreciated. This is the method I code I've been trying to change. (lot is part of an array list) Thanks</p>

<pre><code>    public Lot getLot(int lotNumber)
    {
    if((lotNumber &gt;= 1) &amp;&amp; (lotNumber &lt; nextLotNumber)) {
        Lot selectedLot = lots.get(lotNumber - 1);
        if(selectedLot.getNumber() != lotNumber) {
            System.out.println("Internal error: Lot number " +
                               selectedLot.getNumber() +
                               " was returned instead of " +
                               lotNumber);
            selectedLot = null;
        }
        return selectedLot;
    }
    else {
        System.out.println("Lot number: " + lotNumber +
                           " does not exist.");
        return null;
</code></pre>
