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 are the important features of Java 11 release?
What is meant by anonymous class?
How do I get 64 bit java?
What is externalizable?
What is the main difference between java platform and other platforms?
How java is similar to c?
Class c implements interface I containing method m1 and m2 declarations. Class c has provided implementation for method m2. Can I create an object of class c?
What types of index data structures can you have in java?
What is JVM and is it platform independent?
What are loops in java? What are three types of loops?
What does int argc char * argv [] mean?
What is a file pointer?
What is rule of accessibility in java?
When a thread is executing synchronized methods , then is it possible to execute other synchronized methods simultaneously by other threads?
How do you classify Dialog Box?