Overriding a method contract in an extended interface that uses generics (Java)?

Then you should not use T twice, but like this.

Then you should not use T twice, but like this: public interface Interface { public void myMethod(T x); } public interface ExtendedInterface extends Interface { public void myMethod(V x); } Now it is possible to have something like this: class MyClass implements ExtendedInterface { public void myMethod(String x) { .. } public void myMethod(Integer x) { .. } } Edit: interestingly enough, this also works (although it is useless): class MyClass implements ExtendedInterface { public void myMethod(String x) { .. } }.

This might well be the solution.... Thanks for the practical advice. – badpanda Oct 18 '10 at 17:45 Actually, this causes the same error. – badpanda Oct 18 '10 at 17:48 What version of Java are you using?

In Java 1.6 under Eclipse this works correctly. – Marc Oct 18 '10 at 17:52 @badpanda, that's because you implemented twice the same interface – Colin Hebert Oct 18 '10 at 17:52.

This does work. You could have a problem if your class implements twice the same interface with two different generics types. For example : class MyClass implements Interface, ExtendedInteface{ } For example this code only fails on the third class.

And here is the message I have on IntelliJ X.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions