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

for(int i=0;i<arr.size();i++){
if(arr.get(i) instanceof Integer)
arr.remove(i);
}

Is This Answer Correct ?    5 Yes 4 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is array initialization in java?

497


Why do we override tostring method in java?

513


Explain creating threads by implementing runnable class?

591


What is integers and example?

495


How is hashcode calculated in java?

507






What is navigable map in java?

527


Name few java 8 annotations ?

573


What are synchronized methods and synchronized statements in java programming?

579


why we use merge option in hybernate pls give a ex snippet

1464


Is null function in java?

570


Can I import same package/class twice?

498


Is there any difference between synchronized methods and synchronized statements?

586


What is tcp ip in java?

592


There are two classes named classa and classb. Both classes are in the same package. Can a private member of classa can be accessed by an object of classb?

1005


why are wait(), notify() and notifyall() methods defined in the object class? : Java thread

557