The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes abstract inner classes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "abstract inner classes" Watch "abstract inner classes" New topic

abstract inner classes

Ramnath krishnamurthi
Ranch Hand

Joined: Jan 22, 2003
Posts: 56
Hi all,
How do we extend an abstract inner class?
I tried the following code
class TheOuter{
abstract class TheInner{
class TestInner extends TheOuter.TheInner{
public static void main(String[] args){
I am getting a compile time error that says
"": Error #: 478 : enclosing class innerclasses.TheOuter of class innerclasses.TheOuter.TheInner is not in scope

Any idea how to solve this?
If we cannot extend an innerclass,then what is the use of abstract inner classes?
Thanks in Advance
Feed an Opportunity.Starve a Problem
Krishna Srinivasan
Ranch Hand

Joined: Jul 28, 2003
Posts: 1850

class AbstractInner
abstract class Inner{
abstract void method();
class Inner1 extends Inner{
public void method(){
System.out.println("Implementing Abstract class");
public static void main(String[] args)
new AbstractInner().m();
public void m(){
new AbstractInner.Inner1().method();

Krishna Srinivasan
OCAJP 7/8 Exam, 400+ OCPJP Mock Questions
VP Jain
Ranch Hand

Joined: Feb 11, 2004
Posts: 81
For your question on what is the use of abstract inner classes ?

I would suggest you to view this link Thinking in Java by Bruce Eckel
web page

SCJP SCWCD SCBCD <br /> <br />what u do in life echos in eternity!
I agree. Here's the link:
subject: abstract inner classes
It's not a secret anymore!