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 super () does in java?
What is the difference between menuitem and checkboxmenu item?
What is a bufferedreader?
What are the classes of java?
What is an object in java and how is it created?
What is hashing principle in java?
What is palindrome in java?
How does compareto work in java?
Can we catch more than one exception in a single catch block?
Can a vector contain heterogenous objects?
Which package is used for pattern matching with regular expressions?
what is nested class in java?
How do you find the maximum number from an array without comparing and sorting?
What is purpose of applet programming?
What is java objectoutputstream?