This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Static I.C extending I.C Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Static I.C extending I.C" Watch "Static I.C extending I.C" New topic

Static I.C extending I.C

Shah Chunky
Ranch Hand

Joined: Dec 27, 2000
Posts: 116
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 ?

Shah Chunky - Sun Certified Java2 Programmer.
Thomas Paul
mister krabs
Ranch Hand

Joined: May 05, 2000
Posts: 13974
A ststic inner class can not extend non-static inner classes. It can extend other static inner classes. So this works:
public class Other
static class Osic{}
class Client
static class ClientInner extends Other.Osic{}
Co-Moderator of the Programmer Certification Forums

Associate Instructor - Hofstra University
Amazon Top 750 reviewer - Blog - Unresolved References - Book Review Blog
Shah Chunky
Ranch Hand

Joined: Dec 27, 2000
Posts: 116
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.
I agree. Here's the link:
subject: Static I.C extending I.C
Similar Threads
All Objects always extend "Object"
static inner classes
extending an inner class
how to access class defined in an interface
abstrct inner classes