*
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 8 in Action this week in the Java 8 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: 13884
    
  10

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
Need a link to errata for Java 6 study Guide--Sierra and Bates
Enum overloaded constructer
Question about enums and enhanced for
Enums...
use of " this " ...