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

Q) I have a ArrayList object, in that object i have added 5
integer values, 5 float values, 5 string values. Now
question is how can delete particular type of data ( i.e all
int values or all float values or string values) in that
list object at a time?

Answer Posted / anjan singh

ArrayList al=new ArrayList();
al.add("a");al.add("b");al.add(1);al.add
(2);al.add(1.1);al.add(2.1);
System.out.println("Before:\n");
System.out.println(al);
for(int i=0;i<al.size();)
{

if(al.get(i) instanceof String)
al.remove(i);
else
i++;

}
System.out.println("After:\n");
System.out.println(al);

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are the important features of Java 10 release?

965


How do you create a sop?

951


What is the difference between a constructor and a method?

1182


Why is singleton not thread safe?

1018


What Is Query Throttling in java?

967


What are "methods" and "fields"?

986


Can a list be null in java?

996


Difference between error and exception

5940


What is the purpose of extern variable?

974


What is overriding in java?

1008


What is the formula to calculate percentage?

975


what type of questions asked for barclays technologies pune please send urgent

5618


What are the steps involved to create a bean?

1114


What is double checked locking in singleton?

1018


What do you mean by an interface in java?

981