senzacionale
senzacionale

Reputation: 20906

when implementing interfaces get same interface as superclass

in java i am using generics and in class i want to use implements interface(? extends class) and this interface is generic interface<T> but i get message as

same interface as superclass

code example:

public interface ISomething<T>
{
    string Name { get; set; }
    string GetType(T t);
}

public class SomeClass implements ISomething<T extends SomeClass2>

is this possible?

Upvotes: 0

Views: 112

Answers (1)

John B
John B

Reputation: 32949

You cannot use a generic specifier that is not defined. In your example for SomeClass, T is not declared.

This is invalid:

public class SomeClass implements ISomething<T extends SomeClass2> 

Either of these are valid

public class SomeClass<T extends SomeClass2> implements ISomething<T>

or

public class SomeClass implements ISomething<SomeClass2>  

Upvotes: 2

Related Questions