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
Explain an algorithm to find depth of a binary tree.
Is java good for beginners?
Can we rethrow the same exception from catch handler?
Which class is the superclass for every class in java programming?
What are advantages of exception handling in java?
What is immutable data?
How do you access command-line arguments within the code?
What is meant by bytecode?
What is treeset and treemap in java?
Which is bigger float or double?
How much is a java license?
How do you escape json?
What is the generic class?
What is the meaning of immutable regarding string?
What is the difference between logical data independence and physical data independence?