• Post Reply Bookmark Topic Watch Topic
  • New Topic

Arraylist of HashSets, how to reference  RSS feed

 
bob connolly
Ranch Hand
Posts: 204
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello!

ArrayList ar = null;
HashSet hs = new HashSet();

I have an ArrayList of HashSet objects and i'm wondering how to reference a value in those combined objects!

For instance, after loading the HashSet hs object, hs.add(val), i then assign that HashSet to the ArrayList, ar.add(i,hs)!

So when using these combined objects to validate data, i'm wondering if there is a clean way to reference the values in those combined objects in a statement similar to the following:

ar(i,hs).contains(chkval)

Thanks very much for any ideas!

bc
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This:

would do it. But its not to be advised, since it assumes the ArrayList contains no null values, and is therefore open to NullPointerExceptions.
 
bob connolly
Ranch Hand
Posts: 204
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Paul!

Works great!

Appreciate the help on this!

Have a good week!

bc
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!