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


Please Help Members By Posting Answers For Below Questions

Can we use return in constructor?

483


Which is best ide for java?

512


How is it possible for two string objects with identical values not to be equal under the == operator?

521


Is a method a procedure?

547


Explain the difference between abstract class and interface in java?

528






When should I use singleton?

515


List some important features of java 10 release?

508


What is java developer skills?

502


What do you understand by the term singleton?

575


Is it possible to write a regular expression to check if string is a number?

536


What are the benefits of immutable objects?

532


Which is bigger float or double java?

515


What are the four versions of java?

536


Difference between current previous versions of Java?

549


Define the term string pool?

579