Win a copy of Java Database Connections & Transactions (e-book only) this week in the JDBC forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

Inner and Abstract class  RSS feed

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all


Is it legal(not in terms of syntax) to define inner class inside abstract class does it comes under any design pattern?
 
Marshal
Posts: 64496
225
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You would appear to have missed the JavaRanch naming policy when you signed up. Please check it and amend your displayed name in "my profile."

I think it is legal to declare such an inner class, yes, but if you give it private access it can only be used inside the abstract class. I don't know what pattern name you would put to that.
 
Ranch Hand
Posts: 1970
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Anupama D S:
Is it legal(not in terms of syntax) to define inner class inside abstract class does it comes under any design pattern?



If "not in terms of syntax", then what?

Anyway, the answer is yes, it is legal to have an inner class inside an abstract class.

Further, as well as being legal, it is also sometimes a reasonable thing to do. After all, an abstract class contains (partial) implementation code, and that implementation will sometimes be best achieved with the help of an inner class.
 
Ranch Hand
Posts: 457
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As stated, it would be perfectly reasonable to implement an abstract class, and have one or more inner classes that "complete" the implementation within the same file.

Designs are just names that people have put to common design problem/solutions. It's just likely not that common.
 
I AM MIGHTY! Especially when I hold this tiny ad:
how do I do my own kindle-like thing - without amazon
https://coderanch.com/t/711421/engineering/kindle-amazon
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!