This week's giveaway is in the EJB and other Java EE Technologies forum. We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line! See this thread for details.
this means the object which is currently executing the code, in your case, in which object, you've called the getGrade() method? If this is clear, then you can find the solution for your second question.
|BSc in Electronic Eng| |SCJP 6.0 91%| |SCWCD 5 92%|
Joined: Jul 20, 2010
in the example can you take "GOOD" as a object?explain
thejaka samarakoon wrote:in the example can you take "GOOD" as a object?explain
Yea. every enums are object. They will behave like any other java objects, but in creation and class definition, there are differs. So in your case, you invoke the method getGrade() on GOOD object, and in that method, this means GOOD object. Is it clear?
also I want to add that even if the enums have Constructors we cannot create the objects using the new keyword like we do for classes
we cannot call the enum constructor explicitly
also enum constants have the constant specific bodies which are much similar to the anonymous inner classes
SCJP 6 [86%] June 30th, 2010
OCPWCD [84%] March 26th, 2013
If you find any post useful, click the "plus one" sign on the right