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

Answer Posted / phani raju

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

Is This Answer Correct ?    5 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is tochararray in java?

710


Give a practical example of singleton class usage?

787


What's the difference between an abstract class and interface in java?

795


What is argument in java?

777


Can a class be defined inside an interface?

765


Can we extend singleton class?

722


What is a method in java?

734


what is comparable and comparator interface?

773


How does hashmap work in java ?

756


Explain different forms of polymorphism?

877


How many wrapper classes are there in java?

770


What is public static void main?

801


When is the arraystoreexception thrown?

778


Can you instantiate the math class?

826


When do we use hashset over treeset?

775