Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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

What is multithreading and its advantages?

1017


When will you define a method as static in Java?

994


Which method returns the length of a string?

977


What is the difference between public, private, protected, and friend access?

988


What is the use of predicate in java 8?

891


What are the concepts of 'OOPS'?

1021


Why is a singleton bad?

908


Is it possible to define a method in java class but provide it’s implementation in the code of another language like c?

984


Why java is not 100% object-oriented?

1431


What’s the difference between unit, integration and functional testing?

1047


How do I remove a character from a string in java?

920


What is a java lambda expression?

982


How do you write methodology?

917


Can the garbage collection be forced by any means?

932


What is the function of static in java?

1008