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
What is a static method in java?
What is a default constraint?
What are data structures in java?
What are some characteristics of interference class?
How a string is stored in memory?
What are the problems faced by java programmers who don't use layout managers?
What is preparedstatement in java?
I want my class to be developed in such a way that no other class (even derived class) can create its objects. How can I do so?
What is set in java?
What is a lightweight component?
What is integer parseint?
What is hasnext in java?
Explain the meaning of java applet.
How do you break a loop?
Explain reverse a linked list iterative solution in java?