This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Enum programs are not compiling in java5.0 compiler? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Enum programs are not compiling in java5.0 compiler?" Watch "Enum programs are not compiling in java5.0 compiler?" New topic
Author

Enum programs are not compiling in java5.0 compiler?

Ganeshkumar cheekati
Ranch Hand

Joined: Oct 13, 2008
Posts: 362
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 ]

SCJP5 and SCWCD1.5
Think Twice Act Wise...
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14074
    
  16

Can you post an example of a program that gives you this error? Without an example, it's difficult to help you with this.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
 
wood burning stoves
 
subject: Enum programs are not compiling in java5.0 compiler?
 
Similar Threads
Question about enums and enhanced for
Need a link to errata for Java 6 study Guide--Sierra and Bates
Enums...
use of " this " ...
Enum overloaded constructer