Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

enum used in a code  RSS feed

 
sonia jaswal
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
enum Animals {DOG("woof"), CAT("meow"), FISH("burble");
String sound;
Animals (String s){sound = s ;}
}
class TestEnum
{ static Animals a;
public static void main(String[] args)
{System.out.println(a.DOG.sound + " " + a.FISH.sound);
}
}

Can anybody please explain me this program.... and i also didn't understand the 2nd and 3rd line of the code...
 
Joanne Neal
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
See if this tutorial helps.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!