• Post Reply Bookmark Topic Watch Topic
  • New Topic

Count from an arrayList  RSS feed

 
Nila dhan
Ranch Hand
Posts: 161
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have an arraylist with some set of values.There may be duplicate values also.How to get the count of the number of values without the duplicate values?Any ideas?
 
Julien Grenier
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
here's some ideas :

-You can use a Set (see Set documentation)
-You can iterate through the ArrayList and compare them against each other and count them.
-You can create a new ArrayList and fill it with only unique values.

stuff like that. use your imagination.
 
Nila dhan
Ranch Hand
Posts: 161
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks.I had the idea of using Set.But i thought there would something more sophisticated methods.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!