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 / ggpune
Output will be
size :4
Size after: 2
| Is This Answer Correct ? | 5 Yes | 2 No |
Post New Answer View All Answers
What is instanceof keyword?
What are the different access modifiers available in java?
What are namespaces in java?
What is the function of character?
How can you share data between two thread in Java?
Which class is the superclass for all the classes?
How do you sort in ascending order in java?
List down the methods and interfaces of collection class in java.
What is javac used for?
How do you check if two strings are equal in java?
Is null function in java?
What is the purpose of skeleton and stub?
What is lazy initialization in java?
Why does java not allow multiple public classes in a java file ?
What is a ?