If enum is a class then why don't we declare it with class keyword. I think is'a custom of c, and many programer had used c/c++,(and many old language) To attact the c/c++ programer ,Java kept some custom from C/C++
The example on p. 673 of Head First Java by Kathy Sierra and Bert Bates seems to me to be a "complete program" using an enum - and if you write another class called something like TestEnum and move their main function to that class you should have a pretty good example of the enum's use.
I just finished an expression parser that uses an enum for the arithmetic operations - I could send it to you if you'd like, but since I'm just a beginner it's not so much a "perfect" example of Java programming!
Try experimenting with the Sierra and Bates example - it all becomes more obvious once you've tried out some things with it.
Joined: Jul 22, 2007
Thanks for suggesting the example in Head First Java. Unfortunately, I have the old edition and 'enum' was not discussed in it. I just need to see a working program that uses 'enum'. It would be great if you send me your program. Thanks again.
Joined: Apr 29, 2007
I sent the zipped source files to your gmail address - please let me know if any of it doesn't make sense!