It isn't when you think of it this way. The statement DOG("woof") when you define the enum Animals is actually calling the constructor Animals(String) and hence setting the member sound to "woof". Hence, System.out.println(a.DOG) is simply accessing this constant, calling the toString() method which returns the name of the constant.
posted 8 years ago
Thank you Paul and James.
William Butler Yeats: All life is a preparation for something that probably will never happen. Unless you make it happen.