This week's book giveaway is in the General Computing forum. We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line! See this thread for details.
The code is taken from the K&B book page 62 chapter1 (latest edition). There are many ways to declare an enum. The above is one the way i.e inside a class. But its not working. There's error in compiling. I think the enclosing class name is required...it's as if a nested class.......
I cannot find this example in my K&B Java6 from 2008 although there are many similar examples around page 61-64.
Your example cannot work because if the Coffee class is outsite of CoffeeTest3, how can the compile know what CoffeeSize inside Coffee should be?
If Coffee is put inside CoffeeTest3 as the comment suggests, it works.
Akanksha Joy wrote:
The code is taken from the K&B book page 62 chapter1 (latest edition). There are many ways to declare an enum. The above is one the way i.e inside a class. But its not working. There's error in compiling. I think the enclosing class name is required...it's as if a nested class.......
In class Coffee just type CoffeeTest2.CoffeSize instead of CoffeeSize and everything will be allright.
If you want to reach inner class from outer class you should use the full path. The same if you want to run a class within console and that class is inside a package: then you type -> java package.MyMagicClass
All the best!
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.