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
What is the collection interface?
How do you escape sequences in java?
Can we override data members in java?
What do you understand by access specifiers in Java?
List the different types of classloaders in java.
How do you check if a string contains only numeric digits?
How do I get a substring?
Explain a few methods of overloading best practices in java?
How to read and write image from a file ?
How can you make sure that your singleton class will always return single instance in multi-threaded environment?
For class CFoo { }; what default methods will the compiler generate for you>?
What is sorting in java?
How to perform binary search in java?
Can we make main() thread as daemon?
What is class level lock ?