How do I return the name value of enumerated object by its specific ordinal number?
Here's my code:
import java.util.*
public class Enumarating {
      enum Animals {bunneh , sheep , horse , cow , supercow}
      public static void main(String [] args) {
          Random rand = new Random();
          Animals animal;
      }
}
I will define the random range to 4, and let's say I get number 2. Then I want "horse" to be printed. What method should I use?