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 does system out println () do?
What is static class
Difference between predicate, supplier and consumer ?
How to create a fecelet view?
Is arraylist ordered?
Can a function return a function?
What do you understand by access specifiers in Java?
when you will synchronize a piece of your code? : Java thread
How static variable work in java?
Can we increase array size dynamically in java?
What is stream api in java8?
How will you print number in reverse (descending) order in BST.
Can you call one constructor from another if a class has multiple constructors?
What is math in java?
What is a copy constructor in java?