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

What is ascii format?

782


Can we make a constructor final?

793


What is the final access modifier in java?

839


What is the type of lambda expression?

758


Discuss different types of errors that generally occur while programming.

815


What are the 3 types of control structures?

742


What is the purpose of using java.lang.class class?

771


Can a class be private in java?

773


What is a nested class?

854


How does hashmap work in java ?

769


Why hashcode is used in java?

707


Why string is a class?

752


What is replaceall in java?

799


What is the maximum size of byte array in java?

793


What is the use of default method in interface in java?

793