Enum Anatomy

Rule 2:Prefer using instance field over ordinals

All Enums have ordinal method in them which returns the index of each constant.
Usage: Seldom use it for deriving position of CONSTANTS because adding a new CONSTANT inbetween will make code fragile instead use Instace field like CONSTANT(“this is const”,2)

Published by

Unknown's avatar

sevanand yadav

software engineer working as web developer having specialization in spring MVC with mysql,hibernate

Leave a comment