aspose file tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes I still have problems creating abstract inner classes? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Reply Bookmark "I still have problems creating abstract inner classes?" Watch "I still have problems creating abstract inner classes?" New topic
Author

I still have problems creating abstract inner classes?

josephine chen
Ranch Hand

Joined: Oct 29, 2002
Posts: 216
I am able to craete abstarct static inner classes but not
abstract inner classes
does anybody know how to craete ?Eg please!!
paul wheaton
Trailboss

Joined: Dec 14, 1998
Posts: 19680
    ∞

Here ya go!

It works too!


permaculture forums
josephine chen
Ranch Hand

Joined: Oct 29, 2002
Posts: 216
class T{
abstract class I{
I(){T t = new T();
}
void method(){};
}
class Ne extends T.I{
void method (){
System.out.println("asD");
}
public static void main(String s[]){
Ne n = new Ne();
n.method();
}
}
/*
This is the error iam getting
No enclosing instance of class T is in
scope; cannot create a default
constructor for class Ne.
class Ne extends T.I{
^*/
Thiru Thangavelu
Ranch Hand

Joined: Aug 29, 2001
Posts: 219
The problem with your code is, you are trying to extend an non-static class with without instantiation.
See the I in this -->class Ne extends T.I
This code can be successfully compied if you make the line ----> abstract class I{ ----> static abstract class I{
Let me know if you have probs.


Thanks,<br />Thiru<br />[SCJP,SCWCD,SCBCD]
Francisco A Guimaraes
Ranch Hand

Joined: Mar 20, 2002
Posts: 182
another way to solve the problem:

I know it�s a little more complicated, but i think it�s an worthy alternative. I took this example from Eckel�s "Thinking in Java".
Francisco


Francisco<br />SCJP<br />please use the [code][/code] tags when showing code.Click <a href="http://saloon.javaranch.com/cgi-bin/ubb/ultimatebb.cgi?ubb=ubb_code_page" target="_blank" rel="nofollow">here</a> to see an example.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: I still have problems creating abstract inner classes?
 
Similar Threads
static and abstract inner class
Inner classes
abstract method
Is there a purpose to this?
inner classes