Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

enum question  RSS feed

 
Baheth Haque
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am new to this great board, first I want to thank you all for this java �encyclopedia� .

I have a question, can I use enum where values are database driven in anyway, in another word a variable length enum.

I hope I made my question clear,

Thank you all in advance.
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16028
87
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A "variable length enum"? Do you mean you want to add constants to the enum at runtime? I guess you have a database table that contains a list of constants and you want to make an enum out of this at runtime?

If that's what you mean then no, you can't do this with enums and that's not what enums are meant for. You can write an enum if you know the constants beforehand (at compile time).
 
Baheth Haque
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Jesper, that's exactly what I meant. thank you for your kind reply.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!