File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes can u please explain the ouput of the given code Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Reply locked New topic
Author

can u please explain the ouput of the given code

kapilg gupta
Greenhorn

Joined: Jun 14, 2006
Posts: 10
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);
}
}
output:-woof burble
i want to ask that when sound is assigned the value here as we have not
called constructor also which statement is rsponsible for invoking the constructor
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 13875
    
  10

This is the same question, just stated a little differently.
I already answered in your other thread.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
Naseem Khan
Ranch Hand

Joined: Apr 25, 2005
Posts: 809
I already gave the reply of your question.

Duplicate Post

Please don't post it again

If you have any query, please post in the same thread

regards


Naseem
[ June 16, 2006: Message edited by: Naseem Khan ]

Asking Smart Questions FAQ - How To Put Your Code In Code Tags
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: can u please explain the ouput of the given code
 
Similar Threads
Kathy Sierra Chapter 1 Selftest question 4
Interface question....
enum constructor problem
Static object
please explain the code and please anyone give example of overloading in enum