Enumerations are best used for things that MUST be differentiated in code — business logic. If you use them for data (as your example), this makes no sense to me.
, , , , () .
:
String[] init=new String[] {"WALK", "I am walking", "SKIP", "I am skipping", ...}
Map lookup=new HashMap();
for(int i=0;i+=2;i<init.length)
{
lookup.put(init[i],init[i+1])
}
, , , , , xml , .
, , , "Lookup" ( ). - :
public class Motivate()
{
private static Map<String, Motivate> motivations;
private String action;
private String description;
private Motivate(String action, String description)
{
this.action=action;
this.description=description;
}
public void init()
{
if(motivations == null)
{
build motivations using all the stuff in the first example
}
}
}
( , "" ), , "Runnable" .
"RUN" "WALK", , , , .