wood burning stoves 2.0*
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 Android Security Essentials Live Lessons this week in the Android 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

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
// 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

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
I agree. Here's the link: http://aspose.com/file-tools
subject: Enum programs are not compiling in java5.0 compiler?
Similar Threads
Question about enums and enhanced for
Enum overloaded constructer
Need a link to errata for Java 6 study Guide--Sierra and Bates
use of " this " ...