how to make the right return message
Still struggling whith java in bluejbook (Barnes/Kolling), now question 4.52.
I must search an object (Lot) in an ArrayList (lots) with a number which is a field in that object. Once found, the Lot must be removed. So far so good, but it must also be returned. And when it is not found al null must be returned. I used an Iterator but my code only returns the object when I remove the last. I can see why that is when I look at my code, but I don't know how to solve it. Has anybody got a suggestion what to do?
public Lot removeLot(int number)
Iterator<Lot> it = lots.iterator();
Lot tempLot = null;
tempLot = it.next();
Re: how to make the right return message
Aha I found it. I added just under the part and I removed the else part. cheers.