import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
public class ListRemoveExample {
public static void main(String[] args) {
List<String> ls=new ArrayList<String>();
ls.add("one");
ls.add("Three");
ls.add("two");
ls.add("four");
// remove list object
ls.remove(2); // remove by index number
ls.remove("four"); // remove by object
Iterator it=ls.iterator();
while(it.hasNext())
{
String value=(String)it.next();
System.out.println("Value :"+value);
}
}
}
0 comments:
Post a Comment