hi in the above code i have defined a enum Test. in b and c i have defined a method as argument. now in the last of enum i have defined a test() method without a body. now if i remove this test() from enum Test, the compiler gives error at 1 and 2 in main class. so i am not getting why is it so??? [ August 18, 2008: Message edited by: PUNEET MITTAL ]
yes we are overriding the methods here, but what is the need to override these methods. why cant we read those methods directly in other class by just creating a object to it. like if i dont give test() in the last of enums then can i use the test() methods defined in enum constants b and c. if so then how and if we cannot use them then why??? please tell me this concept, i am totally confused in this.
No. It's like a,b.. are act like instances of the Enum (actually when we say "Enum.Constant" it creates a new object of that type), what we do is overiding those methods defined in the Enum in it's constants. So those methods should be defined in the Enum.