Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Java in General
Search Coderanch
Advance search
Google search
Register / Login
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
Jeanne Boyarsky
Ron McLeod
Paul Clapham
Liutauras Vilda
Sheriffs:
paul wheaton
Rob Spoor
Devaka Cooray
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Carey Brown
Frits Walraven
Tim Moores
Bartenders:
Mikalai Zaikin
Forum:
Java in General
Inner classes query
shyamala vydyam
Greenhorn
Posts: 4
posted 13 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Hi All
I have the following classes !!
class Outer{
class InnerA extends Outer{
}
class InnerB extends InnerA{
// I have the following error while creating this inner classes
// No enclosing instance Outer available due to immediate constructor invocation
}
}
Can any one tell me why we cant extend Inner class with another inner class?
Bit confused with this !!
Thanks,
Shyamala
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
I like...
posted 13 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
class InnerB extends InnerA{ // I have the following error while creating this inner classes // No enclosing instance Outer available due to immediate constructor invocation }
if you want to extend an Innerclass. then you must access with his constructor by enclosing class instance. i.e, some thing like this
class InnerB extends InnerA { InnerB(Outer o) { o.super(); } }
hope this helps
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
I like...
posted 13 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
and Welcome to JavaRanch Shyamala
shyamala vydyam
Greenhorn
Posts: 4
posted 13 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Hi Seetharaman Venkatasamy ,
thats great solution but now the concept looks most contradictory where i cant create a simple object...........
new Outer().new InnerB(new Outer());
this is how we can create the object!!
where exactly this concept can be used!!??
new Outer().new InnerB();
Let me know why is this concept & its use in real time?
Thanks,
Shyamala
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
I like...
posted 13 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
add one no-arg constructor in InnerB
InnerB() { new Outer().super(); }
Campbell Ritchie
Marshal
Posts: 79177
377
posted 13 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Inner classes are too difficult for "beginning".
Thread
moved to another forum.
With a little knowledge, a
cast iron skillet
is non-stick and lasts a lifetime.
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Inherit an inner class
Serialization
Inner Class Constuctors
Inner Classes Constructors
public inner class
Subclassing and Inner Classes -- some examples
Which one to throw??
More...