• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

abstrct inner classes

 
Ranch Hand
Posts: 238
1
Eclipse IDE Fedora Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
I have a situation where i have found that i can declare an abstract class inside a non-abstract class,but then how am i going to extend such an inner class which is abstract.
Please help me out.
Thanks...
 
Sheriff
Posts: 9692
42
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What issue did you face while extending the abstract inner class? It can be easily extended with the syntax extends OuterClass.InnerClass. If your inner class is a non-static inner class, then you'll need an instance of the OuterClass in the constructor of your subclass to call the super constructor...
 
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Inside a class extending the outer class.
 
Sudhanshu Mishra
Ranch Hand
Posts: 238
1
Eclipse IDE Fedora Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the replies.
but:
Ankit says:

If your inner class is a non-static inner class, then you'll need an instance of the OuterClass in the constructor of your subclass to call the super constructor...



This is where i am confused.If the inner class is abstract ,and suppose i extend the inner class by the syntax Outer.Inner, then will i be able to use the members of the inner class directly in my subclass?like they were declared in my subclass itself?
And also if a inner class is abstract and private,then it can never be extended outside the class?
 
Greenhorn
Posts: 13
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


Output :

Inner 2 : 1
Inner 3 : 1
 
Ankit Garg
Sheriff
Posts: 9692
42
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Sudhanshu Mishra wrote:If the inner class is abstract ,and suppose i extend the inner class by the syntax Outer.Inner, then will i be able to use the members of the inner class directly in my subclass?like they were declared in my subclass itself?


The same rules apply in that case as any normal inheritance from a top level class. You would be able to use the non-private members of the inner class in your subclass.

And also if a inner class is abstract and private,then it can never be extended outside the class?


No in that case it can't...
 
Farmers know to never drive a tractor near a honey locust tree. But a tiny ad is okay:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic