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.
Welcome to the Java Programming Forums
The professional, friendly Java community. 21,500 members and growing!
The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.
>> REGISTER NOW TO START POSTING
Members have full access to the forums. Advertisements are removed for registered users.
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?
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..
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.