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...

there are some duplicate values in ArrayList, how U'll get
that array with out duplicate?

Answer Posted / banti

public void removeDuplicateDataFromArrayList(){
ArrayList<String> al = new ArrayList<>();
al.add("a");
al.add("b");
al.add("c");
al.add("c");
al.add("a");

HashSet<String> hs = new HashSet<>();
hs.addAll(al);
al.clear();
al.addAll(hs);
System.out.println("The ArrayList values are :"+ al);

// Or

System.out.println("ArrayList : ");
for (Object data : al) {
System.out.println(data);
}

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is difference between ++ I and I ++ in java?

909


How do you write a conditional statement?

891


Hi i am creating desktop application in that i want calling to mobile number. i have java telephone api (JTAPI) but i dont understand how it configure & use plese help me

1803


What is nested class?

946


If try block is successfully executed, Then Is Finally block executed?

1036


How will you serialize a singleton class without violating singleton pattern?

1898


What do you understand by abstract classes?

1013


What is the purpose of skeleton and stub?

1139


What are locale settings?

932


Can we clone singleton class in java?

906


What is Java Reflection API? Why it’s so important to have?

1072


Which collections are thread safe in java?

883


What is the purpose of void class?

995


What is multi-catch block in java?

1015


What are the benefits of operations?

894