Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

abstract inner classes

 
Ramnath krishnamurthi
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
"TestInner.java": 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
Ramnath
Feed an Opportunity.Starve a Problem
 
Krishna Srinivasan
Ranch Hand
Posts: 1862
Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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();
}
}
 
VP Jain
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic