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 the need of transient variables in Java ?
Can array grow dynamically in java?
Why char array is favored over string for the storage of passwords?
What are some characteristics of interference class?
What is java regex?
Explain the transient field modifier?
Difference between error and exception
How to sort an array from smallest to largest java?
What variables are stored in stack?
What is the basic concept of java?
What is an enumeration?
Does substring start with 0?
What is polymorphism java example?
What is the similarity between dynamic binding and linking?
What is the generic class?