I'm writing a method to remove the minimum item from an arrayList. I have found the minimum item correctly, however, I don't have any clue on the removing method to be honest, I believe the second half of my code is completely useless. Any help is appreciated!
public Comparable remove(){
Iterator<T> iterator=iterator();
T min = iterator.next();
while (iterator.hasNext())
{
T next = iterator.next();
if (min.compareTo(next) > 0)
min = next;
size--;
**Bag<T> newBag=new Bag<T>();
for (int i=0; i<size;i++){
newBag=(Bag<T>) data[i];
System.out.println(newBag);**
}
}
return min;
}