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

Answer Posted / sai



ArrayList list = new ArrayList();
list.add("a");
list.add("b");
list.add("a");
list.add("c");
list.add("b");
HashSet set = new HashSet(list);
list.clear();
list.addAll(set);
System.out.println("ArrayList : ");
for (Object data : list) {
System.out.println(data);

Is This Answer Correct ?    13 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Is integer passed by reference in java?

779


Why chararray() is preferred over string to store the password?

766


What is the role of the java.rmi.naming class?

741


What are java packages?

807


Are global variables initialized to zero?

716


What is java autoboxing?

731


explain what is transient variable in java?

875


How can we create a synchronized collection from given collection?

845


What is == mean?

756


Explain what pure virtual function is?

799


what is the difference between the methods sleep() and wait()? : Java thread

731


Why singleton is not thread safe?

780


What is a constructor, constructor overloading in java?

757


What is string made of?

738


How does predicate work in java?

768