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 use of :: in java?
What is array initialization in java?
Can we define a package statement after the import statement in java?
Does the order of public and static declaration matter in main method?
Is set sorted in java?
How to restrict a member of a class from inheriting by its sub classes?
What is vector capacity in java?
How we can declare a static variable?
What is arguments in java?
Can list be final in java?
What do you mean by thread safe?
Can we instantiate interface in java?
Write a program to search a number in the given list of numbers.
What is class??
Is hashset ordered java?