coolies
coolies

Reputation: 1

Implementing bounded generic with java

I have an interface

public interface TransferObjectUtil<B extends BusinessObject,T> {

    public T to(B domain);

    public B from(T transferObject);
}

I am implementing the class for this as

public class ReflectionBasedTransferObjectUtil<B extends BusinessObject, T> implements
    **TransferObjectUtil<B extends BusinessObject, T>** {

For the portion within the ** in the above line the compiler complains that for B extends BusinessObject is not allowed. Why would it be so ?

I am just starting with generics, so pardon me for my novice question.

Upvotes: 0

Views: 47

Answers (1)

Evan Knowles
Evan Knowles

Reputation: 7501

Your location for the generics is a bit wrong / overeager, try it like this

public class ReflectionBasedTransferObjectUtil<B extends BusinessObject, T> implements TransferObjectUtil<B, T> {

Upvotes: 1

Related Questions