Home > Mobile >  Enum Skeleton Table
Enum Skeleton Table

Time:11-10

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.

CodePudding user response:

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.

  • Related