Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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

Give the hierarchy of inputstream and outputstream classes.

1158


How can we create objects if we make the constructor private ?

1060


What is the constructor?

1097


Can we catch more than one exception in a single catch block?

1132


Explain wait(), notify() and notifyall() methods of object class ?

1112


What is Recursion Function?

1260


What does it mean that a class or member is final?

1050


Can java arraylist hold different types?

1150


Can we access the non-final local variable, inside the local inner class?

1079


Is singleton set an interval?

1019


Difference between object instantiation and construction ?

1109


What happens when main () method is declared as private?

1185


What is illegal identifier in java?

1075


If we allocate the memory using 'new' & de-allocated using 'free' then what will happen?

1089


Write a program to find maximum and minimum number in array?

1045