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 public static void main(string args[]) in java.
Is vector ordered in java?
What restrictions are placed on method overloading?
Why put method is used?
Is 0 true or false?
Can we sort arraylist in java?
What is the function of compareto in java?
Write a program in java to establish a connection between client and server?
What is a default constructor and also define copy contrucyor?
What is super keyword explain with example?
What is a pattern what is an anti pattern?
Is void a wrapper class?
I am unable to find or learn about print command. I have a graphical program in core java in applet but i want to give print command but i have coding for that so if anyone know about this plz mail me on avdhesh_chauhan007@yahoo.co.in
How do you write methodology?
How can you share data between two thread in Java?