Umar Umar - 3 months ago 26
Java Question

Java Generics method argument

I am trying to write an interface method, which will take an argument from a class which extends the common Payload.

public String buildRequest(<T> extends RestServicePayLoad payLoad);

purpose is so that any class that implements RestServicePayLoad can take an argument of that type and return a String.

Looks like my generics format is wrong. Please let me know what is the proper format.


Youre very close

public <T extends RestServicePayLoad> String buildRequest(T payLoad);