What will be the output of the program?
public class Test {
public static void main(String args[]) {
ArrayList<String> list = new ArrayList<String>();
list.add("2");
list.add("3");
list.add("4");
list.add("5");
System.out.println("size :"+list.size());
for(int i=0;i<list.size();i++) {
list.remove(i);
}
System.out.println("size after:"+list.size());
}
}
Answer Posted / surendrababu koppula
ArrayList class remove method example.remove(int index) Removes the element at the specified position in this list. Shifts any subsequent elements to the left.
| Is This Answer Correct ? | 1 Yes | 0 No |
Post New Answer View All Answers
State the difference between strings and arrays.
What is a nonetype?
What are the types of literals?
What are the types of inner classes (non-static nested class) used in java?
What is the use of list in java?
What is difference between equal and == in java?
Why is a singleton bad?
Which software is used for java programming?
What is arrays sort in java?
How many characters is 2 bytes?
Why are getters and setters used?
What is java beans?
What is the platform?
How does varargs work in java?
Is a class subclass of itself?