Re: hierarchy of interface/implementations.
- From: horos11@xxxxxxxxx
- Date: Tue, 24 Mar 2009 17:05:42 -0700 (PDT)
On Mar 24, 3:00 pm, "Matt Humphrey" <ma...@xxxxxxxx> wrote:
<horo...@xxxxxxxxx> wrote in message
news:684f647a-c9e1-419c-8299-89c079c07282@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>I had a quick question about implementing interfaces and storing those
suppose I have a implementation that I defined:
I think you mean interface.
yeah, you are right, I am tired.. :)
public interface MyInterface
public void mymethod();
and I put it in file:
and I want to have several different implementations defined for it,
that I want to stick under:
Can you do this? when I go to make my Implementation1, I sayYou appear to be mixing up the package and class names. The class is not
itself a package that you can put things under. (You can nest classes
within another class, but that's an entirely different issue.)
yeah, I sort of gathered that you couldn't do this, but I think that
is more a limitation of java than anything else. You may argue not so
for interfaces, because you can have a class implement many of them
(and hence the 'inheritance' tree is really a bush), but for an
abstract class - or any arbitrary class for that matter - I think it
is a lot clearer to have an inherited class tied to its parent in a
very clear way.
Consider the whole reader design decision in java. I personally think
is a lot clearer than
because it implicitly shows the relationship between the two classes,
and lends itself to a hierarchy
(like files inside a directory belong to that directory). Likewise,
I'd like to be able to name my class 'File', and hnece say:
Semaphore.File sf = new Semaphore.File()
because I'm using a *type* of Semaphore. I do admit that an abstract
class works better in this case than an interface, but as it is I need
to manually mangle the name to avoid conflict with java's File class.
Anyways, I don't want to make this a big deal, I'll work with it. It's
not like I have any choice. :)
- Prev by Date: Re: Converting linefeeds to ebcdic
- Next by Date: Re: Java in Browser
- Previous by thread: Re: hierarchy of interface/implementations.
- Next by thread: Re: hierarchy of interface/implementations.