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
Is singleton a bad practice?
What is a parameter in simple terms?
What is java thread dump, how can we get java thread dump of a program?
What are the new features in java 8? Explain
Explain about wait() method?
Is char a method in java?
How would you use Bubble Sort to sort the number of elements?
What is a instance variable in java?
Will the compiler creates a default constructor if I have a parameterized constructor in the class?
Give us the name of the list layoutmanagers in java?
What is overriding in java?
Explain the difference between association, aggregation and inheritance relationships.
Can we define package statement after import statement in java?
Difference between arraylist and hashset in java?
What is formatted output?