Results 1 to 4 of 4

Thread: enum

  1. #1
    billq is offline Member
    Join Date
    Dec 2009
    Posts
    25
    Rep Power
    0

    Default enum

    Hello, I am playing with enums and can't figure out how to pass them into a contructor. I have a dog class with enum BREED{LAB, GOLDEN};
    I would like to create a dog object from main using a constructor
    Dog(BREED breed)
    {
    itsBreed = breed;
    }
    In main, when I call

    Dog d1 = new Dog(LAB);

    I get the error that it cannot find symbol BREED.
    Any help will be appreciated
    thanks
    bill

  2. #2
    [RaIdEn] is offline Senior Member
    Join Date
    Oct 2009
    Location
    California,US
    Posts
    201
    Rep Power
    6

    Default

    try BREED.LAB in

    Dog d1 = new Dog(BREED.LAB);

  3. #3
    billq is offline Member
    Join Date
    Dec 2009
    Posts
    25
    Rep Power
    0

    Default

    thanks I needed Dog.BREED.LAB

  4. #4
    [RaIdEn] is offline Senior Member
    Join Date
    Oct 2009
    Location
    California,US
    Posts
    201
    Rep Power
    6

Similar Threads

  1. Using a C enum in Java
    By renukayarkar in forum Advanced Java
    Replies: 3
    Last Post: 10-15-2009, 07:12 PM
  2. Collection of Enum
    By Aldebaranl2 in forum Enterprise JavaBeans (EJB)
    Replies: 0
    Last Post: 12-04-2008, 08:49 AM
  3. Enum example
    By Java Tip in forum java.lang
    Replies: 0
    Last Post: 04-17-2008, 08:34 PM
  4. How to use enum
    By Java Tip in forum java.lang
    Replies: 0
    Last Post: 04-17-2008, 08:34 PM
  5. Enum?
    By vgbhagavan in forum Advanced Java
    Replies: 0
    Last Post: 06-14-2007, 03:02 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •