File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Anonymous Inner Class basic dought

 
Dhanushanth Dhanu
Greenhorn
Posts: 16
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Here if i named all method as m() it is printing A,B........



but if i change the static inner class method name as m1() it is printing A,A.
what is happening here ........
can any one give me a explanation about this............
 
pete stein
Bartender
Posts: 1561
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the source of these questions? Which book or site are you using?

Please see: QuoteYourSources

Much luck!
 
Dhanushanth Dhanu
Greenhorn
Posts: 16
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dhanushanth Dhanu wrote:
Here if i named all method as m() it is printing A,B........



but if i change the static inner class method name as m1() it is printing A,A.
what is happening here ........
can any one give me a explanation about this............
 
Poobhathy Kannan
Ranch Hand
Posts: 94
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In your first example, you override the method m() of A. so when you call x.m(), the overridden method is called and it prints "B".

But in the second, you have a new method m1(). so when you call x.m(), the inherited method is called and prints 'A'.

And i doubt whether you can call it as " static inner class ". it is just a static variable refers to a Anonymous inner class
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic