Làm cách nào để xóa đối tượng cụ thể khỏi ArrayList? Giả sử tôi có một lớp học như sau:Làm thế nào để loại bỏ đối tượng cụ thể khỏi ArrayList trong Java?
import java.util.ArrayList;
public class ArrayTest {
int i;
public static void main(String args[]){
ArrayList<ArrayTest> test=new ArrayList<ArrayTest>();
ArrayTest obj;
obj=new ArrayTest(1);
test.add(obj);
obj=new ArrayTest(2);
test.add(obj);
obj=new ArrayTest(3);
test.add(obj);
}
public ArrayTest(int i){
this.i=i;
}
}
Làm thế nào tôi có thể loại bỏ đối tượng với new ArrayTest(1)
từ ArrayList<ArrayList>
nhưng làm cách nào tôi có thể nhận đối tượng của ArrayTest giống như trước ......... – sanu