Two Laptop Bag
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

problem in arraylist

vijayz devraj

Joined: Apr 03, 2008
Posts: 7
consider a list with values
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

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).


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:
subject: problem in arraylist
jQuery in Action, 3rd edition