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 / 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


Please Help Members By Posting Answers For Below Questions

Explain java coding standards for variables ?

1109


Why map is used in java?

981


What is try-with-resources in java?

1100


What is polymorphism and what are the types of it?

941


What is abstract class constructor called?

952


What is data object example?

938


What is a numeric literal?

995


What are java packages? What is the significance of packages?

954


What is integer valueof?

1041


What is the size of arraylist in java?

976


What is a protected method?

1076


Differentiate between stringbuffer and string?

989


What happens when you invoke a thread’s interrupt method while it is sleeping or waiting?

918


How to calculate the length of a singly linked list in java?

963


Can we synchronize static methods in java?

1038