DarthVader
DarthVader

Reputation: 55062

The type parameter FooEntity is hiding the type FooEntity

public interface IFoo<TKey, FooEntity<TValue>> {
  // stuff
}

I get this error:
The type parameter FooEntity is hiding the type FooEntity

public class FooEntity<T> {

    private T foo;


}

how can i fix this?

I want to be able to implement IFoo Interface somewhere else.

Upvotes: 2

Views: 713

Answers (2)

wks
wks

Reputation: 1148

See this:

public interface IFoo<TKey, FooEntity<TValue>> {
  // stuff
}

You are defining an interface named IFoo. When defining a type, the things between < and > are type parameters. The actual types should be supplied when using this IFoo interface, not when you define IFoo.

Do you really mean this:

public interface IFoo<TKey, TValue> {
    void doSomething(TKey key, FooEntity<TValue> value);
}

And

public class MyFoo implements IFoo<String, Integer> {
    @Override
    public void doSomething(String key, FooEntity<Integer> value) {
        // TODO: ....
    }
}

Upvotes: 4

Java42
Java42

Reputation: 7706

Give this a try...

class FooEntity<K> {  } 

interface IFoo<K,V> {  } 

class IFooImplElseWere<K,V> implements IFoo<K,V> {  }

IFoo<String, FooEntity<String>> ifi = new IFooImplElseWere<String,FooEntity<String>>();

Upvotes: 0

Related Questions