Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

NEED immediate help with enumerated data types JAVA

  1. Sep 22, 2011 #1
    okay so i have my program basically done, i just have one problem and it has to do with an enumerate data type i created

    public enum PaintColor {RED, BLACK, WHITE, BLUE, GREEN, OTHER};

    in my class that is UsedCars
    im tracking attributes of these objects [used cars]
    now...on my TestUsedCars class, im trying to create the object

    but no matter what i type in for paint color it doesnt work:

    UsedCars basicCar = new UsedCars("honda", "9d9d9d9d0", 1999, 120000, x , 99.0);

    'x' is the paintcolor
    by the way, the other values are data fields:
    carmake, vin number, year manufactured, odometer mileage, paintcolor, car condition rating

    i tried putting in RED like i should be able to...or so i thought but it wont work.

    thanks so much guys, i literally know nothing about using enumerated types. they just instructed me to do so and gave me one line of code on how to define the enum....so im struggling figuring out how to do other things with it.

    edit: by the way its beginning JAVA programming, sorry i didnt specify.
  2. jcsd
  3. Sep 23, 2011 #2


    Staff: Mentor

    You should be able to put in RED or BLACK or other value of your enumerated type. When you say "it doesn't work," it would be helpful for you to tell us why it doesn't work. Also, without seeing your code, it's hard to understand what the difficulty is.

    Seeing your code would help, as would the text of any compiler error that is generated.
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook