File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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 Java Interview Guide this week in the Jobs Discussion 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: 15096

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 8 API documentation
I agree. Here's the link:
subject: Enum programs are not compiling in java5.0 compiler?
It's not a secret anymore!