ALLInterview.com :: Home Page            
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
info       Did you received any Funny E-Mails from your Friends and like to share with rest of our friends? Yeah!! you can post that stuff   HERE
Google
   
 
Categories  >>  Software  >>  Java Related  >>  Java J2EE  >>  Core Java
 
 


 

 
 Core Java interview questions  Core Java Interview Questions
 Advanced Java interview questions  Advanced Java Interview Questions
 Swing interview questions  Swing Interview Questions
 EJB interview questions  EJB Interview Questions
 Servlets interview questions  Servlets Interview Questions
 Struts interview questions  Struts Interview Questions
 JDBC interview questions  JDBC Interview Questions
 JMS interview questions  JMS Interview Questions
 SunOne interview questions  SunOne Interview Questions
 J2EE interview questions  J2EE Interview Questions
 Weblogic interview questions  Weblogic Interview Questions
 Websphere interview questions  Websphere Interview Questions
 Java Networking interview questions  Java Networking Interview Questions
 Java J2EE AllOther interview questions  Java J2EE AllOther Interview Questions
Question
there are some duplicate values in ArrayList, how U'll get
that array with out duplicate?
 Question Submitted By :: Sai
I also faced this Question!!     Rank Answer Posted By  
 
  Re: there are some duplicate values in ArrayList, how U'll get that array with out duplicate?
Answer
# 1


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 ?    11 Yes 2 No
Sai
 
  Re: there are some duplicate values in ArrayList, how U'll get that array with out duplicate?
Answer
# 2
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 ?    2 Yes 0 No
Shilpa
 
 
 
  Re: there are some duplicate values in ArrayList, how U'll get that array with out duplicate?
Answer
# 3
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 ?    3 Yes 0 No
Phani Raju
 

 
 
 
Other Core Java Interview Questions
 
  Question Asked @ Answers
 
If circular link of two objects, then will it be garbage collected ? TCS3
what is Portal(web based online portal)? AIG2
What is serializable interface? Infosys13
wht is customised exception? Prudential1
Hi buddy, well i got that there is always a default constructor with abstract class. OK. But why not with interface? Thanks in advance.  2
Java is based on pass by reference or pass by value .. L&T4
Can you call a constructor within a constructor?  7
How are Observer and Observable used?  3
What are null interfaces in JAVA ? and give me some examples?  5
what is the life cycle of jsp? Photon3
if i have one string class then how can you achive this class functionality of this class? Fidelity3
can any body tell me? does advance java and j2ee both are same. Infosys4
 
For more Core Java Interview Questions Click Here 
 
 
 
 
 


   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2012  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com