Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Enum programs are not compiling in java5.0 compiler?

 
Ganeshkumar cheekati
Ranch Hand
Posts: 362
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Enum programs are not compling in java 5.0 compiler.
it is showing the compilation error as
"; expected"

coding is:


class Coffee {
CoffeeSize size;
enum CoffeeSize
{
BIG(8), HUGE(10), OVERWHELMING(16);
// the arguments after the enum value are "passed"
// as values to the constructor
CoffeeSize(int ounces) {
this.ounces = ounces; // assign the value to
// an instance variable
}
private int ounces; // an instance variable each enum
// value has
public int getOunces() {
return ounces;
}
}// each instance of Coffee has-a
// CoffeeSize enum
public static void main(String[] args) {
Coffee drink1 = new Coffee();
drink1.size = CoffeeSize.BIG;
Coffee drink2 = new Coffee();
drink2.size = CoffeeSize.OVERWHELMING;
System.out.println(drink1.size.getOunces()); // prints 8
System.out.println(drink2.size.getOunces()); // prints 16
}
}
can you tell me the reason?
[ October 15, 2008: Message edited by: Ganeshkumar cheekati ]
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15490
43
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you post an example of a program that gives you this error? Without an example, it's difficult to help you with this.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic