public enum Numbers{
One {
public String getDigit(){
return "1";
}
}
,
Two {
public String getDigit(){
return "2";
}
}
,
Three {
public String getDigit(){
return "3";
}
}
};
public static void main (String[] args) throws java.lang.Exception
{
Numbers xyz = Numbers.One;
System.out.println(xyz.getDigit());
}
Above code throws error :
Main.java:38: error: cannot find symbol
System.out.println(xyz.getDigit());
What is the reason for this error? And what is the correct usage for calling declaring methods inside enum for each constants ?