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

Is minecraft 1.15 out?

559


What is the difference between pass by reference and pass by pointer?

508


Why java is made?

573


Can we sort hashset in java?

637


What is jagged array in java?

542






What is the difference between and ?

518


What are mutable classes?

527


Can an integer be a string?

519


Write down program for following scenario. Use java coding standard. You have array list with some words in it..we will call it as dictionary….and you have a arbitrary string containing some chars in it. You have to go through each word of dictionary and find out if that word can be constructed with the help of chars from arbitrary string given. If you find the word print it else print none.

2291


Can I learn java in 3 months?

550


What is the biggest integer?

564


What is protected in java?

536


What is size of int in java?

561


What is the difference between the font and fontmetrics classes in java programming?

509


How to perform selection sort in java?

590