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
What is string subsequence method?
Can we access instance variables within static methods ?
How do you delete a list in java?
What is null data type?
What is abstract class? Explain
How can we make sure main() is the last thread to finish in java program?
What are different types of expressions?
Why do we use return statement?
How to add menushortcut to menu item?
What is the super void?
What are access specifiers in java ?
How do you compare two objects?
What is the difference between the final method and abstract method?
What are the different types of inner classes?
What are the different data types in java?