Re: static methods in interfaces
ballpointpenthief wrote:
Patricia Shanahan wrote:
If you have the class name, but not an instance, you could invoke a
static method directly.
I don't have the class name, I have an Class of TheInterface type.
For what it's worth; I have 6 classes being passed to the same object
(lets call this object Impossible).
I'm having a lot of trouble parsing this paragraph. When you say you
have "an Class" do you mean the java.lang.Class object for the type? I
have no idea what you mean by "being passed to the same object".
Time for another SSC(C)E?
I strongly suspect that interface is not the right way to solve your
design problem, but I don't know enough about the problem to know how to
deal with it. Perhaps you could describe the intent at a higher level?
I suspect one of a few things is going on; including:
- I have overlooked/am confused by something in the language.
- I've just ran into a limitation of Java.
- My design is crap, and no-one programmes like that anyway.
I haven't a clue which one though.
I would hesitate to call another programmer's design "crap", but
otherwise, yes, those are some possibilities. It is very hard to work
out which without knowing what problem the design is intended to solve.
That is why I'm suggesting describing the problem at a higher level.
Patricia