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 / vanjinathan
How it comes 2 after removing the list elements.??
please explain..??
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
What is the vector class in java programming?
Can we assign integer value to char in java?
What does snprintf return?
What is the difference between int and integer in java?
Is multiple inheritance supported by java?
Can we restart a thread already started in java?
What is the purpose of using break in each case of switch statement?
What is private static class in java?
Does java trim remove newline?
Why does java not allow multiple public classes in a java file ?
What is supplier in java?
what is recursion in java
what is the major difference between linkedlist and arraylist in java?
What is regex used for?
What are identifiers in java?