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 / surendrababu koppula
ArrayList class remove method example.remove(int index) Removes the element at the specified position in this list. Shifts any subsequent elements to the left.
Is This Answer Correct ? | 1 Yes | 0 No |
Post New Answer View All Answers
What is an object in java and how is it created?
why using interface interface ?
When is finally block not called?
When we should use serialization?
What is data movement?
Why pass by reference is not possible in java?
Give a brief description of java socket programming?
What is local declaration?
How to read and write image from a file ?
What is the difference between a factory and abstract factory pattern?
What is bytecode verifier?
Who developed java?
What are the features in java?
Are static members inherited to sub classes?
take an array with -ve and +ve value both.find out the nearest value of 0(zero).if two values are same like(-2 and +2)then extract +2 is nearest of 0(zero).