aspose file tools
The moose likes Beginning Java and the fly likes Accessing enums Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "Accessing enums" Watch "Accessing enums" New topic
Author

Accessing enums

midhuna peru
Ranch Hand

Joined: Aug 24, 2012
Posts: 48
Hi guys! I was trying out enums. The following code works fine.

Output is


Now next i was trying to use enum CoffeeSize directly. Here is the code

It shows me the following error.


What does it mean? I din't understand why CoffeeSize is not initialized here and what is happening in previous code regarding this.
Stephan van Hulst
Bartender

Joined: Sep 20, 2010
Posts: 3065
    
    1

This has nothing to do with enums.

You may not access a variable before it's initialized. Member variables get initialized to a default value automatically, if you don't assign a value to them. Local variables do not, you always have to assign a value to them explicitly.
 
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.
 
subject: Accessing enums
 
Similar Threads
enum clarification
can't create enum in inner class
What is Enum?
Scjp6 enum question
enum question