How can I remove specific object from ArrayList? Suppose I have a class as below:
import java.util.ArrayList;
public class ArrayTest {
int i;
pu
AValchev is right. A quicker solution would be to parse all elements and compare by an unique property.
String property = "property to delete";
for(int j = 0; j < i.size(); j++)
{
Student obj = i.get(j);
if(obj.getProperty().equals(property)){
//found, delete.
i.remove(j);
break;
}
}
THis is a quick solution. You'd better implement object comparison for larger projects.