I have a scenario in which I have Player types ARCHER
,WARRIOR
, and sorcerer
.
What should I use in Player class fo
Enum is better to use for type safety. Wrong values cannot be entered. But enum in android takes so much memory, you should use intdef instead. Refer to this answer for Example and explanation:-
IntDef/StringDef Example
You can also check android source code it is replacing enums with IntDef/StringDef wherever possible. Ex. View.VISIBLE.