• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Inner Class

 
kapil apshankar
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Can an inner class be a subclass of the outer class?
I think this is not legal. An inner class can extend any other class or interface.
Correct me if I am wrong.
Regards
Kapil
 
Stevie Kaligis
Ranch Hand
Posts: 400
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
try this :
public class TestClass {
TestClass() {}
TestClass(int x) {}
class Inner extends TestClass {
Inner() {}
Inner(int y) {}
}
public static void main(String[] args) {
new TestClass().new Inner();
}
}

stevie
 
Cindy Glass
"The Hood"
Sheriff
Posts: 8521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can do it, but WHY? You don't gain anything. You already had access to all of the members of the outer class.
 
koray guclu
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can find more about inner classes from http://www.geocities.com/korayguclu/
Take care,

------------------
------------------------
Koray G��l�
(B.s. Computer Engineer)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic