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

Answer Posted / shilpa

List<Integer> arlList=new ArrayList<Integer>();
arlList.add(20);
arlList.add(2);
arlList.add(1);
arlList.add(6);
arlList.add(6);
Set<Integer> tr=new TreeSet<Integer>(arlList);
Iterator<Integer> iterator=tr.iterator();
while(iterator.hasNext()){
System.out.println(iterator.next());
}

Is This Answer Correct ?    4 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Are arrays primitive data types?

640


What are thread safe functions?

514


explain copyonwritearraylist and when do we use copyonwritearraylist?

547


What are scalar data types?

528


Does java support multiple inheritances?

558






Why can we not override static method?

595


Write a java program to generate fibonacci series ?

574


What are register variables what are the advantages?

452


How do you replace all in word?

533


What's the base class in java from which all classes are derived?

747


What's the purpose of static methods and static variables?

600


how to open and edit XML file in Weblogic???

1551


What is a substitution variable?

567


What is close method? How it's different from Finalize & Dispose?

567


What is the access scope of a protected method?

565