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 multithreading and its advantages?
When will you define a method as static in Java?
Which method returns the length of a string?
What is the difference between public, private, protected, and friend access?
What is the use of predicate in java 8?
What are the concepts of 'OOPS'?
Why is a singleton bad?
Is it possible to define a method in java class but provide it’s implementation in the code of another language like c?
Why java is not 100% object-oriented?
What’s the difference between unit, integration and functional testing?
How do I remove a character from a string in java?
What is a java lambda expression?
How do you write methodology?
Can the garbage collection be forced by any means?
What is the function of static in java?