Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Static I.C extending I.C

 
Shah Chunky
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello all...
Static I.C extending I.C
Can someone tell me whether a Static Inner Class can extends a Non Static Inner Class from within the same class or from Other Class ?
Especially how can a static inner class extend other Non static inner class
from Other Outer class.
Can i do something like :-
class Other
{
class Osic{}
}
class Client
{
static class ClienInner extends Other.Osic{}
}
I think the above does'nt work.
So how to extends Other Non Static Inner class ?
Thanks.
 
Thomas Paul
mister krabs
Ranch Hand
Posts: 13974
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A ststic inner class can not extend non-static inner classes. It can extend other static inner classes. So this works:
<pre>
public class Other
{
static class Osic{}
}
class Client
{
static class ClientInner extends Other.Osic{}
}
</pre>
------------------
Co-Moderator of the Programmer Certification Forums
 
Shah Chunky
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This was in JQ+
"A Static inner class cannot extend another Non Static inner class within
the same class, but in general there is no restriction."
So i think it means that v can extend Non static inner class declared outside
the Enclosing class i.e. from other Top Level class.
Can anyone has any input.
Thanks
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic