aspose file tools*
The moose likes Beginning Java and the fly likes problem in arraylist Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "problem in arraylist" Watch "problem in arraylist" New topic
Author

problem in arraylist

vijayz devraj
Greenhorn

Joined: Apr 03, 2008
Posts: 7
consider a list with values
1
2
2
2
5
i need to retrieve data to check whether the data has duplicate or not by using hashcode.
can anyone suggest me through example. just need to diaplay amessage saying that ---yes the data inside has duplicate values
Manuel Leiria
Ranch Hand

Joined: Jul 13, 2007
Posts: 171
Check the contains() method in ArrayList


Manuel Leiria<br /> <br />--------------<br />Peace cannot be kept by force; it can only be achieved by understanding. <br /> Albert Einstein
Rodrigo Tomita
Ranch Hand

Joined: Apr 28, 2008
Posts: 70
Vijayz,

I'm not exactly sure I got your question, however, keep in mind that Lists may contain duplicate values. On the other hand, Sets cannot contain duplicate values. Perhaps you can work with Sets if you don't want duplicate values (or copy the values to a Set and check its size compared to the List).

Regards.

Rodrigo
Shaan Shar
Ranch Hand

Joined: Dec 27, 2005
Posts: 1249

I am not sure, but are you looking something like this:

This has int[] but you can have any other object and compare it accordingly..



The Best way to predict your future is to create it - Every great individual common man
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: problem in arraylist
 
Similar Threads
Maps and Sets
Prevent duplicate data entry
Bug with Data.java - Urgent
how to stop the duplicate values.
how hashmap identify the duplicate values? (i need internal logic)