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


Please Help Members By Posting Answers For Below Questions

What is an example of a conditional statement?

558


What are the three best choices for a development environment?

591


Does sprintf allocate memory?

585


When is the finalize() called?

687


What is the difference between keyword and identifier?

523






How many java versions are there?

556


What is finally in Java?

571


Explain access specifiers?

651


What's the purpose of static methods and static variables?

586


Can we make main() thread as daemon?

566


Which language is java?

536


What is the synchronized method modifier?

581


Break statement can be used as labels in java?

547


Write an algorithm for quick sort?

611


What are invisible components?.

1673