Umar Umar - 1 year ago 126
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.

Answer Source

Youre very close

public <T extends RestServicePayLoad> String buildRequest(T payLoad);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download