• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

abstract inner classes

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hello everyone,

could anyone please tell me how is an abstract inner class implemented by other classes.
some sort of code snippet would be really helpful as iam very confused.

Thanks in advance.
 
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try to write something yourself, compile and run it. If it does not work post it - for discussion and help. You will learn much better that way.
 
Ranch Hand
Posts: 187
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here you go:

public class SychTest
{
abstract public class InnerTest
{
abstract public void test();
}

private class InnerTest1 extends InnerTest
{
public void test()
{
return;
}
} ;
InnerTest1 test1= new InnerTest1();

}
 
Rachana Sharma
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the answer.

Just go through the code and my doubt is why does the compiler show error when we don't extend the outer class and just want to extend the outer.inner in the TestInner.

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
While extending the inner classes, we have to explicitly set some relation between the extending class and the outer class for this inner class. So, the issue is resolved when we go by the second approach. The other approach could be

public class Test{
class TestInner extends Outer.Inner{
TestInner(Outer o){
o.super();
}

public void show(){
System.out.println("in the test1 class!!");
}
}

public static void main(String ar[]){
Test test=new Test();
Outer oo = new Outer();
Test.TestInner in=test.new TestInner(oo);
in.show();
}
}

Hope this solves the issue.
 
Yes, of course, and I accept that blame. In fact, i covet that blame. As does this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic