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
Define how can we find the actual size of an object on the heap?
If you do not want your class to be inherited by any other class. What would you do?
How we can skip finally block of exception even if some exception occurs in the exception block in java?
What is polymorphism java example?
What do you understand by the term polymorphism?
What is the difference between jdk and jre?
Does collectionutils isempty check for null?
Can we create a class inside a class in java?
What are static variables and functions?
What is derived datatype?
a thread is runnable, how does that work? : Java thread
Explain importance of inheritance in java?
How big is a 64 bit float?
How do you sort words in java?
Why is string buffer better than string ?