Are enums meant to be hardcoded? Meaning to hold tons of data?
Sorry that i'm posting a lot, I just really want answers and this forums is a good place to find answers. I want to learn a lot, trust me.
Printable View
Are enums meant to be hardcoded? Meaning to hold tons of data?
Sorry that i'm posting a lot, I just really want answers and this forums is a good place to find answers. I want to learn a lot, trust me.
What do you mean by "hard coded"? Like this?
Code Java:public enum States { OFF, ERROR, START, RESET, END }
Yes, that is how an enum is suppose to function.
It is typically not meant to hold a lot of values because you have to type all of them in manually, but it can.
Try doing some research for yourself: Enum Types (The Java Tutorials)
Well, I meant something along the lines of this..
Code :SAPPHIRERING(1637, 2550, 7, 18, 719, 114, 1), SAPPHIREAMULET(1692, 1727, 7, 18, 719, 114, 1), SAPPHIRENECKLACE(1656, 3853, 7, 18, 719, 114, 1), EMERALDRING(1639, 2552, 27, 37, 719, 114, 2), EMERALDAMULET(1696, 1729, 27, 37, 719, 114, 2), EMERALDNECKLACE(1658, 5521, 27, 37, 719, 114, 2), RUBYRING(1641, 2568, 47, 59, 720, 115, 3), RUBYAMULET(1698, 1725, 47, 59, 720, 115, 3), RUBYNECKLACE(1660, 11194, 47, 59, 720, 115, 3), DIAMONDRING(1643, 2570, 57, 67, 720, 115, 4), DIAMONDAMULET(1700, 2570, 57, 67, 720, 115, 4), DIAMONDNECKLACE(1662, 11090, 57, 67, 720, 115, 4), DRAGONSTONERING(1645, 2572, 68, 78, 721, 116, 5), DRAGONSTONEAMULET(1702, 1712, 68, 78, 721, 116, 5), DRAGONSTONENECKLACE(1664, 11105, 68, 78, 721, 116, 5), ONYXRING(6575, 6583, 87, 97, 721, 452, 6), ONYXAMULET(6581, 6585, 87, 97, 721, 452, 6), ONYXNECKLACE(6577, 11128, 87, 97, 721, 452, 6);
Enums do more than just hold random data.
If you need something to hold tons of data just put it in a text file.
Enums provide a way to make fields of a specific type (the enum type) and give each one methods and/or variables that can be called upon it.