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

How to compare two strings in java program?

1097


Why is a singleton bad?

1001


How do you add an element to an arraylist in java?

993


Why do I need to declare the type of a variable in java?

1150


Write an algorithm for quick sort?

1081


In multi-threading how can we ensure that a resource isn't used by multiple threads simultaneously?

1375


In java, how many ways you can take input from the console?

1038


How many bits is a 64 bit byte?

1136


Name the components that are termed to be Heavy-weight component but available in Light-weight components?

2530


What is the difference between private & public & friendly classes?

1109


What are the advantages of passing this into a method instead of the current class object itself?

1720


How do you sort a string in java?

1013


Which is faster set or list in java?

1075


What is a text string?

1140


How does thread synchronization occurs inside a monitor?

1181