• Post Reply Bookmark Topic Watch Topic
  • New Topic

Is possible set of enums in Java? enumSet?  RSS feed

 
Ranch Hand
Posts: 90
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In Pascal I have code:


There is enum type and set of enums - need for filter. How can i write similar program in Java?
 
Bartender
Posts: 4181
22
IntelliJ IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does the EnumSet class do what you need? I don't know pascal so I can't tell.
 
Andrzej Borucki
Ranch Hand
Posts: 90
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have not use EnumSet yet, it is possible give it as parameter? like func([meA,meC]) ?
 
Steve Luke
Bartender
Posts: 4181
22
IntelliJ IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is an object, so yes you can pass a reference to it to methods just like any other object.
 
Saloon Keeper
Posts: 7993
143
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, but you should use the Set interface instead:
 
Sheriff
Posts: 3752
62
Chrome Netbeans IDE Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nitpick: I'd use Set<TMyEnum> filter instead of Set<? extends TMyEnum> filter. All enum classes are implicitly and unavoidably final, so using wildcards doesn't add any benefit.
 
Stephan van Hulst
Saloon Keeper
Posts: 7993
143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Uhhh true. It's become a bit of a habit of mine.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!