Simply do this: public Class2 getTwo() { return new Class2(); } If you're overriding a method public T getTwo(), the compiler will allow you to declare your impl as public Class2 getTwo() when your T for your impl is Class2.
The first compilation error occurs because type parameters declared by methods are specified by the caller, not the method implementation. That is, given class Class3 extends BaseClass implements Interface { ... } a caller may write Class3 c3 = new Class1().getTwo(); , but the method implementation returns a Class2, which isn't a subtype of T = Class3. The second compilation error occurs because type parameters that aren't explicitly specified by the caller are inferred from method arguments and the type of the variable the method return value is assigned to.
This inference fails here. The usual workaround, recommended by the Java Language Specification, is to specify the type parameters explicitly in such cases (type inference is intended as a convenience for simple cases; it doesn't aim to cover all cases). As for how to properly declare this type parameter, I'd need to know what you are trying to accomplish with these declarations.
1 Good answer. I think the syntax would be new Class1().getTwo() in your second code example though. – Kublai Khan 3 hours ago Oh, of course.
Thanks, fixed. – meriton 3 hours ago.
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.