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


Please Help Members By Posting Answers For Below Questions

Explain public static void main(string args[]) in java.

708


Is vector ordered in java?

710


What restrictions are placed on method overloading?

856


Why put method is used?

750


Is 0 true or false?

702


Can we sort arraylist in java?

767


What is the function of compareto in java?

788


Write a program in java to establish a connection between client and server?

699


What is a default constructor and also define copy contrucyor?

833


What is super keyword explain with example?

742


What is a pattern what is an anti pattern?

690


Is void a wrapper class?

715


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

1804


How do you write methodology?

726


How can you share data between two thread in Java?

713