package
javaRadarArrayList;
import
java.util.ArrayList;
public class RemoveAtIndex {
public static void main(String[] args) {
//create Array
List
ArrayList<String>
javaRadarList = new
ArrayList<String>();
//Add elements
to ArrayList
javaRadarList.add("Java");
javaRadarList.add("Jquery");
javaRadarList.add("Spring");
javaRadarList.add("Hibernate");
javaRadarList.add("EJB");
System.out.println("Before
Removal");
for(String list : javaRadarList){
System.out.println(list);
}
//Remove
element from 2nd position
javaRadarList.remove(1);
System.out.println("After
Removal");
for(String list : javaRadarList){
System.out.println(list);
}
}
}
OUTPUT:
Java
Jquery
Spring
Hibernate
EJB
After Removal
Java
Spring
Hibernate
EJB
Compare the result and you will find that element at 2nd position(Jquery) will not appear in After Removal result.
No comments:
Post a Comment