Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: Java
Expertise: Intermediate
Apr 12, 2004

Check for Duplicates in an ArrayList

This is a simple method to check for duplicates in an ArrayList:


checkDuplicate : Method

public static boolean checkDuplicate(ArrayList list) {
 HashSet set = new HashSet();
 for (int i = 0; i < list.size(); i++) {
  boolean val = set.add(list.get(i));
  if (val == false) {
  	return val;
  }
 }
 return true;
}
Vijayanandraj Amaladoss
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap