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.

Results 1 to 4 of 4

Thread: enums..

  1. #1
    Member
    Join Date
    Dec 2011
    Posts
    34
    My Mood
    Cheerful
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default enums..

    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.


  2. #2
    Super Moderator helloworld922's Avatar
    Join Date
    Jun 2009
    Posts
    2,895
    Thanks
    23
    Thanked 619 Times in 561 Posts
    Blog Entries
    18

    Default Re: enums..

    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)

  3. #3
    Member
    Join Date
    Dec 2011
    Posts
    34
    My Mood
    Cheerful
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: enums..

    Quote Originally Posted by helloworld922 View Post
    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);

  4. #4
    Member
    Join Date
    Jun 2011
    Posts
    182
    My Mood
    Where
    Thanks
    15
    Thanked 8 Times in 8 Posts

    Default Re: enums..

    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.

Similar Threads

  1. CONVERT ENUMS TO GET METHOD??
    By Me360 in forum What's Wrong With My Code?
    Replies: 0
    Last Post: October 28th, 2011, 07:56 PM
  2. How To Use Enums
    By Json in forum Java Programming Tutorials
    Replies: 6
    Last Post: October 16th, 2009, 04:17 PM
  3. How To Use Enums
    By Json in forum Java Code Snippets and Tutorials
    Replies: 6
    Last Post: October 16th, 2009, 04:17 PM
  4. switch with Enums
    By chronoz13 in forum Loops & Control Statements
    Replies: 17
    Last Post: October 8th, 2009, 08:08 PM