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
Does java linked list allow duplicates?
How big is a gigabyte?
Why string is not a wrapper class?
How many bits is a boolean?
When is the finally clause of a try-catch-finally statement executed?
What is main in java?
What are the difference between string, string builder, and string buffer in java?
What is the purpose of a volatile variable?
How do you call a reference in java?
How do you classify Dialog Box?
What is main difference between variable and constant?
Can we make constructors static?
How do you check if a character in a string is a digit or letter?
How can I become a good programmer?
What is the use of coding?