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

Explain an algorithm to find depth of a binary tree.

990


Is java good for beginners?

964


Can we rethrow the same exception from catch handler?

1079


Which class is the superclass for every class in java programming?

938


What are advantages of exception handling in java?

975


What is immutable data?

992


How do you access command-line arguments within the code?

1003


What is meant by bytecode?

964


What is treeset and treemap in java?

1003


Which is bigger float or double?

919


How much is a java license?

868


How do you escape json?

938


What is the generic class?

904


What is the meaning of immutable regarding string?

910


What is the difference between logical data independence and physical data independence?

980