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%], OCPWCD [84%], OCEJPAD [83%]
If you find any post useful, click the "plus one" sign on the right