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

Explain differences between collection api and stream api?

612


List down the methods and interfaces of collection class in java.

543


how to split string in java?

652


How to add menushortcut to menu item?

565


Is the empty set a singleton?

540






Is final static java?

549


What does null mean in java?

629


What is a java object and java application?

576


What is a container in a gui?

548


What is getclass () getname () in java?

680


What are the differences between include directive and include action?

546


how we can create packages in java?

520


What is number data type?

532


why would you use a synchronized block vs. Synchronized method? : Java thread

537


Does hashset allow duplicates in java?

580