I have a Arraylist object, it has duplecate values also. Now
question is i want delete duplecate data in that objet with
out using Set?
Answer Posted / gopal
Hey sorry. There is a small correction to the above code
/**
Remove duplicates from ArrayList<String> without using Set
*/
private static void removeDuplicates (ArrayList<String> al) {
for (int i=0;i <al.size(); i++) {
int index = al.lastIndexOf(al.get(i));
while (index != -1 && index != i) {
al.remove(i);
index = al.lastIndexOf(al.get(i));
}
}
}
| Is This Answer Correct ? | 2 Yes | 0 No |
Post New Answer View All Answers
How can the checkbox class be used to create a radio button?
what is thread? : Java thread
In a container there are 5 components. I want to display the all the components names, how will you do that one?
How to make a non daemon thread as daemon?
How concurrent hashmap works?
What are the access modifiers available in java?
What is the difference between a field variable and a local variable?
Define inheritance?
Which is the class in java?
How does list work in java?
What does void * mean?
What is the independent variable in an experiment?
What are different types of multitasking?
What is reverse function?
What do you mean by a JVM?