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 / murli
solution without taking time complexity into account
List arr = new ArrayList();
for(int i=0;i<count;i++){
for(int j=i+1;j<count;j++){
if(arr.get(i)!=null && arr.get(i).equals(arr.get(j))){
arr.set(j, null);
}
}
}
while(arr.contains(null))
arr.remove(null);
| Is This Answer Correct ? | 2 Yes | 5 No |
Post New Answer View All Answers
Is minecraft 1.15 out?
What is externalizable?
What are the methods to rectify ambiguities in the interfaces in JAVA?
Is Constructor possible in abstract class in java ?
Can a constructor call the constructor of parent class?
What are the three parts of a lambda expression? What is the type of lambda expression?
Can you extend main method in java?
Explain the difference between an Interface and an Abstract class?
How does linkedlist work in java?
How many bytes is a char in java?
What is structure of java heap? What is perm gen space in heap?
How do you decide when to use arraylist and linkedlist?
What are exceptions
What is a databasemetadata?
What are the restrictions imposed by a Security Manager on Applets?.