Hi All.....i'm a novice in java....just started learning...hope this forum helps me to gain more knowledge in java.....My question is how do we call a method from the same class.....
here is my code: i'm trying to implement interface, inheritance, method over riding, anonymous class and interface reference all in this program.....the code worked fine without method overriding and anonymous class....have highlighted the error statement in red.....can someone please say where i have gone wrong........
The error on the line 45 from your code is you are instantiating a subclass for an abstract class which is not completely defined. Use the following way instead
Secondly the error on line 54 is you are trying to restrict the access modifier, as the methods in an interface are always public , where as you are changing it to default access.
Please let me know if something is unclear
Joined: May 30, 2013
Hi Shashank Gollapudi
Thanks for your quick response. your comments helped. the code is working fine now :-)
Please clarify the following too:
Does this mean we are creating an instance for an "Abstract" anonymous class. why i am mentioning abstract is it includes just 1method of the interface. is my understanding right?
Also how can i have interface reference for an abstract class without including pop(int) in the example given. i tried as follows
It gave me a compiler error stating anonymous class is not abstract and doesnt override method pop(int). while creating a reference variable for an abstract class should the anonymous class definitely invoke the method in the interface that is left out in the abstract class?. then wats the point in creating an abstract class?...quiet confusing.