Skip to content
Advertisement

Enum Skeleton Table

Hello I’m just wondering if there is anyone that could make sense of this java skeleton code table for an enum class. Table:

enter image description here

My code currently is this:

public enum SkyCondition
{
    SUNNY,
    SNOWY,
    CLOUDY,
    RAINY
}

Is that it? or am I supposed to incorporate the int in some way? Thank you.

Advertisement

Answer

Every enum includes two properties by default:

public final String name(); // name like SUNNY, SNOWY, CLOUDY, RAINY
public final int ordinal(); // the position in enum declaration: 0 - for SUNNY, 1 - SNOWY, etc.

so, int is already incorporated into enum.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement